Created
October 13, 2011 08:29
-
-
Save ab5tract/1283741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'i3-ipc' | |
i3 = I3::IPC.new | |
def process(data) | |
data.each do |ws| | |
if ws["focused"] | |
writeScript ws["name"] | |
else | |
next | |
end | |
end | |
end | |
def writeScript(name) | |
File.open('/home/me/.scripts/gv', 'w') do |f| | |
f.puts("#!/usr/bin/env zsh\ngvim --servername #{name} --remote-tab-silent $1") | |
end | |
end | |
I3::IPC.subscribe [:workspace] do |em, type, data| | |
case type | |
when I3::IPC::MESSAGE_REPLY_GET_WORKSPACES | |
process(data) | |
when I3::IPC::EVENT_WORKSPACE | |
em.send_data I3::IPC.format(I3::IPC::MESSAGE_TYPE_GET_WORKSPACES) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment