sway-rename-workspace
This commit is contained in:
parent
4237e7954d
commit
9b0261fec0
1 changed files with 24 additions and 0 deletions
24
.local/bin/sway-rename-workspace
Executable file
24
.local/bin/sway-rename-workspace
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/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.."'"))
|
Loading…
Reference in a new issue