Class: Lingvo::GUI::Notify

Inherits:
Object
  • Object
show all
Defined in:
lib/lingvo/gui/notify.rb

Class Method Summary collapse

Class Method Details

.runObject



34
35
36
37
38
# File 'lib/lingvo/gui/notify.rb', line 34

def run
  word = Lingvo::Models::English.rand(1).first
  Console.no_word if word.nil?
  show word.eng, word.ru
end

.show(eng, ru) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lingvo/gui/notify.rb', line 5

def show(eng, ru)
  conf = Config.notify

  first = conf[:prefix] + (conf[:first] == 'eng' ? eng : ru)
  second = conf[:separate] + (conf[:first] == 'eng' ? ru : eng) + conf[:sufix]

  if Console.which('twmnc')
    command = 'twmnc'
    command += " -t '#{first}'"
    command += " -c '#{second}'"
    command += " --bg '#{conf[:twmnc_bg]}'"
    command += " --fg '#{conf[:twmnc_fg]}'"
    command += " -i '#{conf[:image]}'"
    command += " -d #{conf[:timeout].to_i}"

  elsif Console.which('notify-send')
    command = 'notify-send -u normal'
    command += " -t #{conf[:timeout].to_i}"
    command += " -i '#{conf[:image]}'"
    command += " '#{first}#{second}'"

  else
    puts 'Please install notify-send or twmn(twmnc) notification system'
    exit
  end

  system command
end