Skip to content

Instantly share code, notes, and snippets.

@senko
Created April 17, 2023 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save senko/4478ebb09962cbc5b033f57a13981c24 to your computer and use it in GitHub Desktop.
Save senko/4478ebb09962cbc5b033f57a13981c24 to your computer and use it in GitHub Desktop.
sway-toggle-tabs
#!/bin/bash
#
# Cycle through all workspaces and set them to tabbed if "small" and
# split horizontally if "big". "Small" is defined as having width less
# than 2880, otherwise it's big.
#
# Looks a bit messy for a split second, but then returns to the current
# workspace.
workspaces_json="$(swaymsg -t get_workspaces)"
current_ws=$(echo "$workspaces_json" | jq '.[]|select(.focused==true).num')
small_workspaces=$(echo "$workspaces_json" | jq '.[] | select(.rect.width < 2880) | .num')
big_workspaces=$(echo "$workspaces_json" | jq '.[] | select(.rect.width >= 2880) | .num')
for ws in $small_workspaces; do
swaymsg "workspace number $ws"
swaymsg "layout tabbed"
done
for ws in $big_workspaces; do
swaymsg "workspace number $ws"
swaymsg "layout splith"
done
swaymsg "workspace number $current_ws"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment