class WM::Desktop

Public Class Methods

all() click to toggle source
# 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) click to toggle source
# 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

Public Instance Methods

active?()
Alias for: current?
current?() click to toggle source
# File lib/epitools/wm.rb, line 48
def current?
  current
end
Also aliased as: active?
windows() click to toggle source
# File lib/epitools/wm.rb, line 54
def windows
  @windows ||= WM.windows.select { |w| w.desktop_id == num }
end