Class: Swm::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/swm/window.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Window

Returns a new instance of Window.



10
11
12
# File 'lib/swm/window.rb', line 10

def initialize(id)
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/swm/window.rb', line 4

def id
  @id
end

Class Method Details

.currentObject



6
7
8
# File 'lib/swm/window.rb', line 6

def self.current
  Window.new `xdotool getwindowfocus`.to_i
end

Instance Method Details

#heightObject



18
19
20
# File 'lib/swm/window.rb', line 18

def height
  xwininfo_integer_property "Height"
end

#move(x, y) ⇒ Object



30
31
32
33
34
# File 'lib/swm/window.rb', line 30

def move(x, y)
  x ||= pos_x
  y ||= pos_y
  set x, y, width, height
end

#pos_xObject



22
23
24
# File 'lib/swm/window.rb', line 22

def pos_x
  xwininfo_integer_property "Absolute upper-left X"
end

#pos_yObject



26
27
28
# File 'lib/swm/window.rb', line 26

def pos_y
  xwininfo_integer_property "Absolute upper-left Y"
end

#set(x, y, w, h) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/swm/window.rb', line 36

def set(x, y, w, h)
  x ||= pos_x
  y ||= pos_y
  w ||= width
  h ||= height
  command = "wmctrl -i -r #{@id} -e 0,#{x},#{y},#{w},#{h}"
  system command
  raise "Error running #{command}" unless $?.success?
  clear_cache
end

#widthObject



14
15
16
# File 'lib/swm/window.rb', line 14

def width
  xwininfo_integer_property "Width"
end