Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ab5tract
Created October 13, 2011 08:29
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 ab5tract/1283741 to your computer and use it in GitHub Desktop.
Save ab5tract/1283741 to your computer and use it in GitHub Desktop.
#!/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