.dotfiles/configs/sway/toggle_layout.sh

26 lines
702 B
Bash
Raw Normal View History

2021-11-08 01:29:28 +01:00
#!/bin/bash
WORKSPACE=$(swaymsg -t get_workspaces --raw | jq '.[] | select(.focused == true)')
2021-11-22 18:45:44 +01:00
WORKSPACE_ID=$(echo $WORKSPACE | jq ".name" | tr -d '"')
2021-11-08 01:29:28 +01:00
WORKSPACE_MODE=$(echo $WORKSPACE | jq ".layout");
MODE_SPLITH='"splith"'
MODE_SPLITV='"splitv"'
MODE_TABBED='"tabbed"'
MODE_STACKED='"stacked"'
2021-11-22 18:45:44 +01:00
function set_layout(){
swaymsg "workspace $(swaymsg -t get_workspaces --raw | jq '.[] | select(.focused == true) .name'); layout $1"
}
2021-11-08 01:29:28 +01:00
if [ $WORKSPACE_MODE = $MODE_SPLITH ]; then
2021-11-22 18:45:44 +01:00
set_layout splitv
2021-11-08 01:29:28 +01:00
elif [ $WORKSPACE_MODE = $MODE_SPLITV ]; then
2021-11-22 18:45:44 +01:00
set_layout tabbed
2021-11-08 01:29:28 +01:00
elif [ $WORKSPACE_MODE = $MODE_TABBED ]; then
2021-11-22 18:45:44 +01:00
set_layout stacking
2021-11-08 01:29:28 +01:00
elif [ $WORKSPACE_MODE = $MODE_STACKED ]; then
2021-11-22 18:45:44 +01:00
set_layout splith
2021-11-08 01:29:28 +01:00
fi