Class: Cadre::Libnotify::Notifier

Inherits:
Notifier
  • Object
show all
Defined in:
lib/cadre/libnotify/notifier.rb

Instance Attribute Summary

Attributes inherited from Notifier

#app_name, #expire_time, #message, #sound, #summary, #transient

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Notifier

#available?, availables, get, #initialize, register, registry

Constructor Details

This class inherits a constructor from Cadre::Notifier

Class Method Details

.available?Boolean


8
9
10
# File 'lib/cadre/libnotify/notifier.rb', line 8

def self.available?
  return availables["notify-send"]
end

Instance Method Details

#goObject


12
13
14
15
16
17
18
19
20
21
# File 'lib/cadre/libnotify/notifier.rb', line 12

def go
  cmd = "notify-send #{options} \"#@summary\" \"#@message\""
  %x[#{cmd}]

  if available?("paplay")
    %x[paplay #{Valise.find(["sounds", sound]).full_path}] if String === sound
  elsif available?("aplay")
    %x[aplay #{Valise.find(["sounds", sound]).full_path}] if String === sound
  end
end

#optionsObject


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cadre/libnotify/notifier.rb', line 23

def options
  options = []
  unless expire_time.nil?
    options << "-t #@expire_time"
  end

  if transient
    options << "-h \"byte:transient:1\""
  end

  unless app_name.nil?
    options << "-a #@app_name"
  end

  options.join(" ")
end