sway workspace switching

This commit is contained in:
end-4
2024-01-25 13:15:58 +07:00
parent 830f6a780d
commit f14d3146db
3 changed files with 27 additions and 8 deletions
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Get the current workspace number
current=$(swaymsg -t get_workspaces | gojq '.[] | select(.focused==true) | .num')
# Check if a number was passed as an argument
if [[ "$1" =~ ^[+-]?[0-9]+$ ]]; then
new_workspace=$((current + $1))
else
new_workspace=$((current + 1))
fi
# Check if the new workspace number is out of bounds
if [[ $new_workspace -lt 1 ]]; then
exit 0
fi
# Switch to the new workspace
swaymsg workspace $new_workspace