Skip to content

Instantly share code, notes, and snippets.

@emdeeeks
Forked from janx/dmenu_goto_window.rb
Created May 28, 2024 00:05
Show Gist options
  • Save emdeeeks/689352064f787cfe166571148101df7f to your computer and use it in GitHub Desktop.
Save emdeeeks/689352064f787cfe166571148101df7f to your computer and use it in GitHub Desktop.
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
# bring up dmenu prompt, ask user to choose from window names in the tmp file
selected = `dmenu -i -fn Tamzen-12 -l 10 -p 'Goto window: ' < /tmp/dmenu_goto_windows`.strip
# find window data using its name
win = window_list.find {|w| w[3] == selected }
# switch to the window
`bspc window -f #{win[0]}` if win
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment