25 lines
691 B
Plaintext
Executable file
25 lines
691 B
Plaintext
Executable file
#!/usr/bin/env lua5.1
|
|
|
|
-- https://stackoverflow.com/a/326715
|
|
function os.capture(cmd, raw)
|
|
local f = assert(io.popen(cmd, 'r'))
|
|
local s = assert(f:read('*a'))
|
|
f:close()
|
|
if raw then return s end
|
|
s = string.gsub(s, '^%s+', '')
|
|
s = string.gsub(s, '%s+$', '')
|
|
s = string.gsub(s, '[\n\r]+', ' ')
|
|
return s
|
|
end
|
|
|
|
local rename_to = os.capture("echo | fuzzel-run --dmenu")
|
|
local workspace_number = os.capture("swaymsg -t get_workspaces | jq '.[] | select(.focused).num'")
|
|
|
|
local workspace_new_name = workspace_number .. ": " .. rename_to
|
|
|
|
if #rename_to == 0 then
|
|
workspace_new_name = workspace_number
|
|
end
|
|
|
|
assert(os.execute("swaymsg rename workspace to '"..workspace_new_name.."'"))
|