Class: WM::Desktop

Inherits:
Object show all
Defined in:
lib/epitools/wm.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject


27
28
29
30
31
32
33
34
35
36
# File 'lib/epitools/wm.rb', line 27

def self.all
  # 0  - DG: 1680x1050  VP: N/A  WA: 0,25 1680x974  Workspace 1
  # 1  - DG: 1680x1050  VP: N/A  WA: 0,25 1680x974  Workspace 2
  # 2  * DG: 1680x1050  VP: 0,0  WA: 0,25 1680x974  Workspace 3
  # 3  - DG: 1680x1050  VP: N/A  WA: 0,25 1680x974  Workspace 4
  # 4  - DG: 1680x1050  VP: N/A  WA: 0,25 1680x974  Workspace 5
  # 5  - DG: 1680x1050  VP: N/A  WA: 0,25 1680x974  Workspace 6
  # 0  1 2   3          4   5    6   7    8         9
  `wmctrl -d`.lines.map(&:strip).map { |line| Desktop.from_line(line) }
end

.from_line(line) ⇒ Object


38
39
40
41
42
43
44
45
46
# File 'lib/epitools/wm.rb', line 38

def self.from_line(line)
  fields = line.split
  fields[1] = (fields[1] == "*") # cast to boolean
  fields[5] = nil if fields[5] == "N/A" # N/A becomes nil

  name = fields[9..-1].join(" ")

  new *(fields.values_at(0,1,3,5,8) + [name])
end

Instance Method Details

#current?Boolean Also known as: active?


48
49
50
# File 'lib/epitools/wm.rb', line 48

def current?
  current
end

#windowsObject


54
55
56
# File 'lib/epitools/wm.rb', line 54

def windows
  @windows ||= WM.windows.select { |w| w.desktop_id == num }
end