Last active
August 15, 2020 22:40
-
-
Save kwon37xi/68a7ea43759ba270e9ae224d314b959a to your computer and use it in GitHub Desktop.
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 | |
# Gnome 3 based workspace changer | |
# only works with gnome 3 vertical workspace | |
# workspace-switcher.sh Up | |
# workspace-switcher.sh Down | |
# | |
# ref : https://www.artificialworlds.net/blog/2011/03/04/switching-workspace-in-gnome-via-the-command-line/ | |
CMD="$1" | |
NUM_WORKSPACES=`gsettings get org.gnome.desktop.wm.preferences num-workspaces` | |
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
https://gist.github.com/kwon37xi/3173fda9047d2782372e6f9cb5bd70df 이걸 사용할 것.