class Swm::Window
Attributes
id[R]
Public Class Methods
current()
click to toggle source
# File lib/swm/window.rb, line 6 def self.current Window.new `xdotool getwindowfocus`.to_i end
new(id)
click to toggle source
# File lib/swm/window.rb, line 10 def initialize(id) @id = id end
Public Instance Methods
height()
click to toggle source
# File lib/swm/window.rb, line 18 def height xwininfo_integer_property "Height" end
move(x, y)
click to toggle source
# File lib/swm/window.rb, line 30 def move(x, y) x ||= pos_x y ||= pos_y set x, y, width, height end
pos_x()
click to toggle source
# File lib/swm/window.rb, line 22 def pos_x xwininfo_integer_property "Absolute upper-left X" end
pos_y()
click to toggle source
# File lib/swm/window.rb, line 26 def pos_y xwininfo_integer_property "Absolute upper-left Y" end
set(x, y, w, h)
click to toggle source
# 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
width()
click to toggle source
# File lib/swm/window.rb, line 14 def width xwininfo_integer_property "Width" end
Private Instance Methods
clear_cache()
click to toggle source
# File lib/swm/window.rb, line 85 def clear_cache @xwininfo = nil end
xwininfo()
click to toggle source
xwininfo will tell stuff about the requested window
Sample output:
xwininfo: Window
id: 0x3c00862 “xwininfo -id 62916706”
Absolute upper-left X: 1 Absolute upper-left Y: 52 Relative upper-left X: 0 Relative upper-left Y: 0 Width: 992 Height: 596 Depth: 32 Visual: 0x6c Visual Class: TrueColor Border width: 0 Class: InputOutput Colormap: 0x3c00005 (not installed) Bit Gravity State: NorthWestGravity Window Gravity State: NorthWestGravity Backing Store State: NotUseful Save Under State: no Map State: IsViewable Override Redirect State: no Corners: +1+52 -927+52 -927-432 +1-432 -geometry 110x33+-7+24
# File lib/swm/window.rb, line 77 def xwininfo @xwininfo ||= `xwininfo -id #{@id}` end
xwininfo_integer_property(name)
click to toggle source
# File lib/swm/window.rb, line 81 def xwininfo_integer_property(name) /#{name}: +(\d+)/.match(xwininfo)[1].to_i end