mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
Added script which switches to the workspace which a window is being moved to, if
that action makes the current workspace empty.
This commit is contained in:
parent
8e990604ca
commit
ec6ec0b226
16
.scripts/i3cmds/i3switchempty
Executable file
16
.scripts/i3cmds/i3switchempty
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Original sript below modified to not use `jq` for improved performance (~4 times as fast) and no dependencies.
|
||||||
|
# https://github.com/tasinet/i3-switch-if-workspace-empty/blob/master/i3-switch-if-workspace-empty.sh
|
||||||
|
|
||||||
|
new_workspace=$1
|
||||||
|
|
||||||
|
if [ "" == "$new_workspace" ]; then
|
||||||
|
echo expecting workspace name/number
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
active_workspace=$(i3-msg -t get_workspaces | grep -Po '[0-9]*","visible":[a-z]*,"focused":true' | head -c1)
|
||||||
|
|
||||||
|
toplevel_containers=$(i3-msg -t get_tree | grep -Po "\"num\":$active_workspace.*" | grep -Po '"nodes":(\d*?,|.*?[^\\]",)' | head -n1 | grep -Po '"nodes":\[\]')
|
||||||
|
|
||||||
|
[ "$toplevel_containers" != "" ] && i3-msg workspace $new_workspace
|
||||||
Loading…
x
Reference in New Issue
Block a user