Skip to content

Instantly share code, notes, and snippets.

@janx
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janx/d08fbc1006f7183b14a4 to your computer and use it in GitHub Desktop.
Save janx/d08fbc1006f7183b14a4 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