class XDo
- XDo
- Reference
- Object
Overview
XDo is a Crystal interface for libxdo,
the C library that backs xdotool.
It exposes most of the functionality of xdotool, allowing
users to write Crystal programs that manage windows in an X11 instance.
The easiest way to use XDo is via XDo.act:
XDo.act do
active_window do |win|
win.type "hello from Crystal!"
end
end
Defined in:
x_do.crx_do/enums.cr
x_do/libxdo.cr
x_do/version.cr
Constant Summary
-
DEFAULT_DELAY =
12000 -
VERSION =
"0.8.3"
Constructors
-
.new(display = ENV["DISPLAY"]?)
Creates a new
XDoinstance with the given X11 display.
Class Method Summary
-
.act(&)
Yields a block with an
XDoinstance, providing a DSL for interaction. -
.lib_version
Returns the version of
libxdobeing used as aString. -
.symbol_map
Returns a
Hash(String, String)indicating the current symbol map.
Instance Method Summary
-
#active_modifiers
Returns a list of
XDo::LibXDo::Charcodemaps indicating all active modifier keys. -
#active_window
Returns the
Windowthat is currently active. -
#active_window(&)
Returns the
Windowthat is currently active. -
#clear_active_modifiers
TODO implement
-
#desktop
Returns the current desktop's number.
-
#desktop=(desktop)
Sets the current desktop.
-
#desktops
Returns the number of desktops.
-
#desktops=(ndesktops)
Sets the number of desktops.
-
#disable_feature(feature : XDoFeatures)
Disable an
xdofeature. - #display : String | Nil
-
#enable_feature(feature : XDoFeatures)
Enable an
xdofeature. -
#finalize
Destroys the instance's internal state.
-
#focused_window(*, sane = true)
Returns the
Windowthat currently has focus. -
#focused_window(*, sane = true, &)
Returns the
Windowthat currently has focus. -
#has_feature?(feature : XDoFeatures)
Test whether a feature is enabled.
-
#input_state : KeyMask
Returns the input state, which is the
ORof any active modifiers in theKeyMask. -
#mouse_location
Returns the mouse's current position as a tuple of
xandycoordinates, thescreenit's on, and theWindowit's over. -
#mouse_window
Returns the
Windowthat the mouse is currently over. -
#mouse_window(&)
Returns the
Windowthat the mouse is currently over. -
#move_mouse(x, y, screen)
Moves the mouse to coordinates x, y on the given screen.
-
#move_mouse(x, y)
Moves the mouse to coordinates x, y relative to its current position.
- #on_mouse_move(&)
-
#on_mouse_move_from(x, y, &)
Wait for the mouse to move from the coordinates x, y.
-
#on_mouse_move_to(x, y, &)
Wait for the mouse to move to the coordinates x, y.
- #search(query)
-
#search(&)
Like
#search(query), but yields a block to build the query directly. -
#select_window
Returns the
Windowselected interactively. -
#select_window(&)
Returns the
Windowselected interactively. -
#set_active_modifiers
TODO implement
-
#viewport
Gets the desktop viewport as an
x,ytuple. -
#viewport=(tup)
Sets the desktop viewport (only relevant if
_NET_DESKTOP_VIEWPORTis supported). -
#viewport_dimensions(screen)
Gets the dimensions of the given screen's viewport as a
width,heighttuple. -
#wait_for_mouse_move_from(x, y)
Wait for the mouse to move from the coordinates x, y.
-
#wait_for_mouse_move_to(x, y)
Wait for the mouse to move to the coordinates x, y.
Constructor Detail
Creates a new XDo instance with the given X11 display.
# create an instance on the default display or `DISPLAY` env variable
xdo = XDo.new
# ...or with a different X display
xdo2 = XDo.new(":2")
# ... do some work ...
Class Method Detail
Yields a block with an XDo instance, providing a DSL for interaction.
XDo.act do
select_window do |win|
win.unmap!
sleep 1
win.map!
win.type "hello"
end
desktop = 3
end
Returns a Hash(String, String) indicating the current symbol map.
XDo.symbol_map # => {"alt" => "Alt_L", "ctrl" => "Control_L"}
Instance Method Detail
Returns a list of XDo::LibXDo::Charcodemaps indicating all active modifier keys.
Returns the Window that currently has focus.
When sane is set to true, returns the first ancestor-or-self window
with the WM_CLASS property. When set to false, returns the actual focused
window (which may not be the application's top-level window).
Returns the Window that currently has focus.
When sane is set to true, returns the first ancestor-or-self window
with the WM_CLASS property. When set to false, returns the actual focused
window (which may not be the application's top-level window).
Returns the input state, which is the OR of any active modifiers
in the KeyMask.
Returns the mouse's current position as a tuple of x and y coordinates,
the screen it's on, and the Window it's over.
x, y, screen, win = xdo.mouse_location
Takes a Search and runs it, returning a list of Windows matching the search.
XDo.act do
query = XDo::Search.build { window_name "Firefox" }
winds = search(query)
puts winds
end
Like #search(query), but yields a block to build the query directly.
XDo.act do
winds = search { window_name "Firefox" }
puts winds
end
Sets the desktop viewport (only relevant if _NET_DESKTOP_VIEWPORT is supported).
XDo.act do
viewport = {x, y}
end
Gets the dimensions of the given screen's viewport as a width, height tuple.