Skip to content

Instantly share code, notes, and snippets.

View emdeeeks's full-sized avatar

Gareth Griffiths emdeeeks

View GitHub Profile
@emdeeeks
emdeeeks / xlib.rb
Created May 27, 2024 22:35 — forked from ohac/xlib.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'ffi'
module X11
extend FFI::Library
ffi_lib 'X11'
attach_function :open_display, :XOpenDisplay, [:pointer], :pointer
attach_function :query_tree, :XQueryTree,
[:pointer, :int, :pointer, :pointer, :pointer, :pointer], :int
attach_function :get_window_attributes, :XGetWindowAttributes,
@emdeeeks
emdeeeks / scrot.rb
Created May 27, 2024 22:37 — forked from lian/scrot.rb
# % ruby scrot.rb /tmp/screenshot.png
# scrot.rb uses xlib + imlib via ffi to capture screenshots.
require 'ffi'
module X11
extend FFI::Library
ffi_lib 'X11'
attach_function :XOpenDisplay, [:string], :pointer
attach_function :XFlush, [:pointer], :pointer
@emdeeeks
emdeeeks / win_class_title.rb
Created May 27, 2024 23:26 — forked from tmtm/win_class_title.rb
X のウィンドウのクラスとタイトルを取得する
require 'ffi'
module FFI
typedef :pointer, :Display
typedef :ulong, :XID
typedef :XID, :Window
typedef :int, :Status
typedef :ulong, :Atom
end
@emdeeeks
emdeeeks / dmenu_goto_window.rb
Created May 28, 2024 00:05 — forked from janx/dmenu_goto_window.rb
Jump to specified window (archlinux + bspwm + dmenu)
#!/usr/bin/env ruby
# get a list of all windows
window_list = `wmctrl -l`.split("\n").map {|l| l.strip.split(' ', 4)}
# write window names to a tmp file
File.open('/tmp/dmenu_goto_windows', 'w') do |f|
window_list.each {|w| f.puts w[3] }
end
@emdeeeks
emdeeeks / main.rb
Created March 5, 2025 22:40 — forked from amirrajan/main.rb
Gauntlet written in DragonRuby Game Toolkit
class Game
attr_gtk
def tick
defaults
render
input
calc
end