Created
March 13, 2016 21:54
-
-
Save atilberk/3f27e506d5cce62cd4f1 to your computer and use it in GitHub Desktop.
A little shell script for expanding and shrinking workspaces
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/sh | |
# Usage: | |
# ./resize-workspace.sh [expand|shrink] | |
command=$1 | |
vsize=$(dconf read /org/compiz/profiles/unity/plugins/core/vsize) | |
hsize=$(dconf read /org/compiz/profiles/unity/plugins/core/hsize) | |
total=$((hsize * vsize)) | |
if [ "$command" = "expand" ]; then | |
if [ "$total" = 1 ]; then | |
dconf write /org/compiz/profiles/unity/plugins/core/hsize 2 | |
notify-send "Resize Workspace" "Workspace expanded to 2x1 successfully" | |
elif [ "$total" = 2 ]; then | |
dconf write /org/compiz/profiles/unity/plugins/core/vsize 2 | |
notify-send "Resize Workspace" "Workspace expanded to 2x2 successfully" | |
elif [ "$total" = 4 ]; then | |
dconf write /org/compiz/profiles/unity/plugins/core/hsize 3 | |
notify-send "Resize Workspace" "Workspace expanded to 3x2 successfully" | |
elif [ "$total" = 6 ]; then | |
dconf write /org/compiz/profiles/unity/plugins/core/vsize 3 | |
notify-send "Resize Workspace" "Workspace expanded to 3x3 successfully" | |
elif [ "$total" = 9 ]; then | |
dconf write /org/compiz/profiles/unity/plugins/core/hsize 4 | |
notify-send "Resize Workspace" "Workspace expanded to 4x3 successfully" | |
else | |
notify-send "Resize Workspace" "Cannot expand more: Size limit reached" | |
fi | |
elif [ "$command" = "shrink" ]; then | |
if [ "$total" = 12 ]; then | |
dconf write /org/compiz/profiles/unity/plugins/core/hsize 3 | |
notify-send "Resize Workspace" "Workspace shrank to 3x3 successfully" | |
elif [ "$total" = 9 ]; then | |
dconf write /org/compiz/profiles/unity/plugins/core/vsize 2 | |
notify-send "Resize Workspace" "Workspace shrank to 3x2 successfully" | |
elif [ "$total" = 6 ]; then | |
dconf write /org/compiz/profiles/unity/plugins/core/hsize 2 | |
notify-send "Resize Workspace" "Workspace shrank to 2x2 successfully" | |
elif [ "$total" = 4 ]; then | |
dconf write /org/compiz/profiles/unity/plugins/core/vsize 1 | |
notify-send "Resize Workspace" "Workspace shrank to 2x1 successfully" | |
elif [ "$total" = 2 ]; then | |
dconf write /org/compiz/profiles/unity/plugins/core/hsize 1 | |
notify-send "Resize Workspace" "Workspace shrank to 1x1 successfully" | |
else | |
notify-send "Resize Workspace" "Cannot shrink more: Size limit reached" | |
fi | |
else | |
echo "Wrong argument: $1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment