Class: Barabara::Modules::WindowName
- Inherits:
-
Object
- Object
- Barabara::Modules::WindowName
- Includes:
- Wisper::Publisher
- Defined in:
- lib/barabara/modules/wname.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ WindowName
constructor
A new instance of WindowName.
- #watch ⇒ Object
Constructor Details
#initialize ⇒ WindowName
Returns a new instance of WindowName.
7 8 9 |
# File 'lib/barabara/modules/wname.rb', line 7 def initialize @cmd = 'xtitle -sf "%s\n"' end |
Class Method Details
.limit(line) ⇒ Object
11 12 13 |
# File 'lib/barabara/modules/wname.rb', line 11 def self.limit(line) line.length > 80 ? line[0..60].gsub(/\s\w+\s*$/, '…') : line end |
Instance Method Details
#watch ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/barabara/modules/wname.rb', line 15 def watch PTY.spawn(@cmd) do |stdout, _stdin, pid| stdout.each do |line| title = WindowName.limit(line.chomp) publish(:event, 'window_title', title) end Process.wait pid end end |