Created
August 15, 2020 22:40
-
-
Save kwon37xi/3173fda9047d2782372e6f9cb5bd70df to your computer and use it in GitHub Desktop.
workspace-switcher.sh
This file contains 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 | |
# workspace-switcher.sh [num-of-workspace] [Down/Up] | |
CMD="$2" | |
NUM_WORKSPACES=$1 | |
CURRENT_WS=`wmctrl -d | grep \* | cut -d " " -f 1` | |
MOVE_UP="-1" | |
MOVE_DOWN="+1" | |
case $CMD in | |
"Up" ) | |
WS_COL=`echo $CURRENT_WS "%" $NUM_WORKSPACES | bc` | |
if [[ $WS_COL -eq 0 ]]; then | |
{ | |
NEW_WS=$CURRENT_WS | |
} | |
else | |
{ | |
NEW_WS=`echo $CURRENT_WS "- 1" | bc` | |
}; fi | |
;; | |
"Down" ) | |
NEW_WS=`echo $CURRENT_WS "+ 1" | bc` | |
NEW_WS_COL=`echo $NEW_WS "%" $NUM_WORKSPACES | bc` | |
if [[ $NEW_WS_COL -eq 0 ]]; then NEW_WS=$CURRENT_WS; fi | |
;; | |
* ) | |
NEW_WS=$CMD | |
esac | |
wmctrl -s $NEW_WS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment