Last active
February 24, 2019 14:19
-
-
Save felipecwb/a8d8ac1119d2390655172acab44aad1c to your computer and use it in GitHub Desktop.
Gnome Switch to next active workspace!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
orientation=$1 | |
if [ "$orientation" != "next" ] \ | |
&& [ "$orientation" != "previous" ]; | |
then | |
orientation="next" | |
fi | |
actualWS="$(wmctrl -d | grep -P "^\d+ \* " | cut -d' ' -f1)" | |
activesWS="$(wmctrl -l | cut -f3 -d' ' | sort | uniq)" | |
firstWS="$(echo "$activesWS" | head -n1)" | |
lastWS="$(echo "$activesWS" | tail -n1)" | |
next() { | |
n=$(($actualWS + 1)) | |
for i in $(seq $n 1 $lastWS); do | |
[ -z "$i" ] && break | |
x=$(echo "$activesWS" | grep $i) | |
[ -n "$x" ] && break | |
done | |
[ -n "$x" ] \ | |
&& echo $x \ | |
|| echo $firstWS | |
exit 0 | |
} | |
previous() { | |
n=$(($actualWS - 1)) | |
if [ $n -lt $firstWS ]; then | |
echo $lastWS | |
exit 0 | |
fi | |
for i in $(seq $n -1 $firstWS); do | |
[ -z "$i" ] && break | |
x=$(echo "$activesWS" | grep $i) | |
[ -n "$x" ] && break | |
done | |
[ -n "$x" ] \ | |
&& echo $x \ | |
|| echo $lastWS | |
exit 0 | |
} | |
wmctrl -s $($orientation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment