Skip to content

Instantly share code, notes, and snippets.

@stormbrew
Created April 6, 2016 21:43
Show Gist options
  • Save stormbrew/d770dc5119cc14c14ec33b85f1c23192 to your computer and use it in GitHub Desktop.
Save stormbrew/d770dc5119cc14c14ec33b85f1c23192 to your computer and use it in GitHub Desktop.
i3wm ctrl-p for window switching
bindsym $mod+o exec i3-msg '[id='$(i3-msg -t get_tree | jq -r 'recurse(.nodes[]) | select(.window) | (.window | tostring) + ":" + .name' | ~/.config/bin/dmenu_map -i)'] focus'
bindsym $mod+Mod1+o exec i3-msg '[id='$(i3-msg -t get_tree | jq -r 'recurse(.nodes[]) | select(.window and .urgent) | (.window | tostring) + ":" + .name' | ~/.config/bin/dmenu_map -i)'] focus'
#!/usr/bin/env ruby
item_counter = Hash.new {|h,k| h[k] = 0 }
items = {}
STDIN.each_line do |line|
id, str = line.chomp.split(':', 2)
counter_str = if item_counter[str] > 0
"(#{item_counter[str]})"
else
""
end
item_counter[str] += 1
items["#{str} #{counter_str}"] = id
end
IO.popen(["dmenu", *ARGV], "r+", :err=>[:child, :out]) do |dmenu|
items.each do |str, id|
dmenu.puts(str)
end
dmenu.close_write
res = dmenu.gets
puts(items[res.chomp])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment