Class: Barabara::Modules::EventProcessor

Inherits:
Object
  • Object
show all
Includes:
Wisper::Publisher
Defined in:
lib/barabara/modules/event_processor.rb

Instance Method Summary collapse

Instance Method Details

#event(command, args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/barabara/modules/event_processor.rb', line 7

def event(command, args)
  return false if command == ''

  # STDERR.puts "Got command \"#{command}\": #{args.inspect}."
  out = case command
        when 'tagline', 'battery', 'weather', 'time', 'volume'
          { command.to_sym => args }
        when /^(focus|window_title)_changed$/
          { window_title: Modules::WindowName.limit(args[1] || '') }
        when 'window_title'
          { window_title: sanitize_window_title(args || '') }
        else
          warn "Unknown event \"#{command}\": " + args.inspect
          {}
        end
  publish(:update_panel, out)
end

#sanitize_window_title(title) ⇒ Object



25
26
27
# File 'lib/barabara/modules/event_processor.rb', line 25

def sanitize_window_title(title)
  title.gsub('%{', '%%{')
end