38 lines
752 B
Shell
Executable file
38 lines
752 B
Shell
Executable file
#!/bin/sh
|
|
|
|
# Jump to the first empty workspace
|
|
#
|
|
# Triggered by <Super>n
|
|
# as defined in [org/gnome/settings-daemon/plugins/media-keys]
|
|
# in ~/.config/gnome-settings/key-bindings.ini
|
|
#
|
|
# Note: This assumes that only the main monitor has workspaces enabled
|
|
# (see ~/.local/bin/move-window-to-empty-workspace)
|
|
|
|
set -eu
|
|
|
|
|
|
occupied=$(wmctrl -l) || exit 1 # fail safe
|
|
occupied=$(echo "$occupied" | awk '{print $2}' | sort -u)
|
|
|
|
total=$(wmctrl -d | wc -l)
|
|
|
|
|
|
# 0-based index for the first workspace
|
|
i=0
|
|
|
|
while [ "$i" -lt "$total" ]; do
|
|
|
|
if ! echo "$occupied" | grep -qx "$i"; then
|
|
exec wmctrl -s "$i"
|
|
fi
|
|
|
|
i=$((i + 1))
|
|
|
|
done
|
|
|
|
|
|
command -v notify-send >/dev/null \
|
|
&& notify-send 'Workspaces' 'No empty workspace available'
|
|
|
|
exit 1
|