puntos/.local/bin/sway-switch_workspace

24 lines
618 B
Plaintext
Executable file

#!/usr/bin/luajit
local direction = arg[1]
local move = arg[2]
--local file = io.popen "swaymsg -t get_outputs -r | jq -r '.[] | select(.focused == true) | .name'"
local file = io.popen "swaymsg -t get_workspaces -r | jq -r '.[] | select(.focused == true) | .name'"
local string = file:read '*a'
print(string)
local command = 'workspace'
if move == 'move' then
command = 'move container to workspace'
end
if direction == 'next' then
os.execute('swaymsg '..command..' '..string+1)
elseif direction == 'prev' then
if string+0 ~= 1 then
os.execute('swaymsg '..command..' '..string-1)
end
end