2021-11-08 01:29:28 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
WORKSPACE=$(swaymsg -t get_workspaces --raw | jq '.[] | select(.focused == true)')
|
|
|
|
|
2022-04-08 15:47:38 +02:00
|
|
|
|
2021-11-22 18:45:44 +01:00
|
|
|
WORKSPACE_ID=$(echo $WORKSPACE | jq ".name" | tr -d '"')
|
2022-04-08 15:47:38 +02:00
|
|
|
WORKSPACE_MODE=$(swaymsg -t get_tree | jq 'recurse(.nodes[]) | select(.nodes[].focused == true).layout');
|
|
|
|
echo "WORKSPACE: $WORKSPACE_MODE"
|
2021-11-08 01:29:28 +01:00
|
|
|
|
|
|
|
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
|
2022-04-08 15:47:38 +02:00
|
|
|
# elif [ $WORKSPACE_MODE = $MODE_TABBED ]; then
|
|
|
|
# set_layout stacking
|
2021-11-08 01:29:28 +01:00
|
|
|
elif [ $WORKSPACE_MODE = $MODE_TABBED ]; then
|
2021-11-22 18:45:44 +01:00
|
|
|
set_layout splith
|
2021-11-08 01:29:28 +01:00
|
|
|
fi
|
2022-04-08 15:47:38 +02:00
|
|
|
|
|
|
|
if [ "$1" != "" ]; then
|
|
|
|
set_layout $1
|
|
|
|
fi
|