Created
May 16, 2014 07:27
-
-
Save markusfisch/cbbad6b4338296182cd5 to your computer and use it in GitHub Desktop.
bash script to easily switch to next workspace in Ubuntu compbiz using wmctrl
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
#!/usr/bin/env bash | |
# Switch to next viewport | |
next_viewport() | |
{ | |
if (( X+VIEWPORT_WIDTH >= TOTAL_WIDTH )) | |
then | |
X=0 | |
if (( Y+VIEWPORT_HEIGHT >= TOTAL_HEIGHT )) | |
then | |
Y=0 | |
else | |
(( Y += VIEWPORT_HEIGHT )) | |
fi | |
else | |
(( X += VIEWPORT_WIDTH )) | |
fi | |
wmctrl -o $X,$Y | |
} | |
# Run given function for each workspace | |
# | |
# @param ... - function and arguments (optional) | |
workspace() | |
{ | |
wmctrl -d | while read IDX STAR DG TOTAL VP VPN WA WAN VIEWPORT NA | |
do | |
local TOTAL_WIDTH=${TOTAL%x*} | |
local TOTAL_HEIGHT=${TOTAL#*x} | |
local WA_WIDTH=${WAN%,*} | |
local WA_HEIGHT=${WAN#*,} | |
local VIEWPORT_WIDTH=${VIEWPORT%x*} | |
local VIEWPORT_HEIGHT=${VIEWPORT#*x} | |
local X=${VPN%,*} | |
local Y=${VPN#*,} | |
(( VIEWPORT_WIDTH += WA_WIDTH )) | |
(( VIEWPORT_HEIGHT += WA_HEIGHT )) | |
${@:-next_viewport} | |
done | |
} | |
if [ $BASH_SOURCE == $0 ] | |
then | |
workspace ${@:-next_viewport} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment