Skip to content

Instantly share code, notes, and snippets.

@kwon37xi
Created August 15, 2020 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwon37xi/3173fda9047d2782372e6f9cb5bd70df to your computer and use it in GitHub Desktop.
Save kwon37xi/3173fda9047d2782372e6f9cb5bd70df to your computer and use it in GitHub Desktop.
workspace-switcher.sh
#!/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