Project

xlib

0.01
No commit activity in last 3 years
No release in over 3 years
Talk to X11 using ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.9
 Project Readme

Simple 1:1 interface to Xlib for ruby

This gem just wraps Xlib including Xrender and Xrandr and makes its interface available in ruby through ffi. Xlib documentation can be found in its manual. No functions have been renamed or abstracted away in some objects. It's just the plain Xlib API.

For a lightweight wrapper and a more ruby style access to X11 have a look at ruby-xlib-objects.

Installation

gem install xlib

Usage

The API lives in the Xlib namespace.

display_pointer = Xlib.XOpenDisplay(':0')
display = Xlib::Display.new(display_pointer)

screens = (0..display[:nscreens]-1).map do |number|
  screen_pointer = display[:screens] + number*Xlib::Screen.size
  Xlib::Screen.new(screen_pointer)
end

root_windows = screens.map do |screen|
  Xlib.XRootWindowOfScreen(screen.pointer)
end

root_window_sizes = root_windows.map do |root_win|
  attributes = Xlib::WindowAttributes.new
  Xlib.XGetWindowAttributes(display.pointer, root_win.pointer, attributes.
    pointer)
  { width: attributes[:width], height: attributes[:height] }
end