From 8ffd9be38739c511064eec00180187a79fdd8af6 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sun, 26 Feb 2023 14:46:14 +0100 Subject: [PATCH] add script to switch to empty workspace --- roles/i3/files/config | 2 ++ roles/i3/files/scripts/empty_ws.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 roles/i3/files/scripts/empty_ws.sh diff --git a/roles/i3/files/config b/roles/i3/files/config index 6cdb7c0..945d8f5 100644 --- a/roles/i3/files/config +++ b/roles/i3/files/config @@ -178,3 +178,5 @@ mode "$mode_apps" { bindsym Escape mode "default" bindsym Return mode "default" } + +bindsym $mod+grave exec --no-startup-id ~/.config/i3/scripts/empty_ws.sh diff --git a/roles/i3/files/scripts/empty_ws.sh b/roles/i3/files/scripts/empty_ws.sh new file mode 100755 index 0000000..d4847ca --- /dev/null +++ b/roles/i3/files/scripts/empty_ws.sh @@ -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