add script to switch to empty workspace

This commit is contained in:
Pim Kunis 2023-02-26 14:46:14 +01:00
parent d4f3467519
commit 8ffd9be387
2 changed files with 29 additions and 0 deletions

View file

@ -178,3 +178,5 @@ mode "$mode_apps" {
bindsym Escape mode "default" bindsym Escape mode "default"
bindsym Return mode "default" bindsym Return mode "default"
} }
bindsym $mod+grave exec --no-startup-id ~/.config/i3/scripts/empty_ws.sh

View file

@ -0,0 +1,27 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
wss=`i3-msg -t get_workspaces | tr , '\n' | grep num | cut -d : -f 2 | sort -n`
nextwss=()
for ws in $wss; do
((ws=$ws+1))
nextwss+=( "$ws" )
done
for nextws in ${nextwss[@]}; do
exists=false
for ws in $wss; do
if [[ $ws -eq $nextws ]]; then
exists=true
break
fi
done
if [ $exists = false ]; then
newws=$nextws
break
fi
done
i3-msg workspace $newws