Created
August 14, 2015 06:13
-
-
Save frangio/90f9d806db766ba4c40c to your computer and use it in GitHub Desktop.
Lua script to switch to next empty workspace in i3wm. Depends on i3ipc-lua.
This file contains hidden or 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 lua | |
i3ipc = require 'i3ipc' | |
conn = i3ipc.Connection() | |
tree = conn:get_tree() | |
ws = {} | |
for _, w in pairs(tree:workspaces()) do | |
if w.focused then | |
conn:command('workspace ' .. w.name) | |
os.exit(true, true) | |
end | |
ws[w.name] = true | |
end | |
curr = tonumber(tree:find_focused():workspace().name) | |
if not curr then | |
curr = 1 | |
end | |
for w = curr+1, curr+9 do | |
w = (w - 1) % 10 + 1 | |
if not ws[tostring(w)] then | |
conn:command('workspace ' .. w) | |
os.exit(true, true) | |
end | |
end | |
os.exit(false, true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment