Skip to content

Instantly share code, notes, and snippets.

@SergKolo
Created April 23, 2016 18:36
Show Gist options
  • Save SergKolo/d77dd46e9d936b5871e1829a2afd79c3 to your computer and use it in GitHub Desktop.
Save SergKolo/d77dd46e9d936b5871e1829a2afd79c3 to your computer and use it in GitHub Desktop.
Short script to associate coordinates and positional numbers of viewports through an array
$> cat viewports.sh
#!/bin/bash
get_screen_geometry()
{
xwininfo -root | awk '/-geometry/{gsub(/+|x/," ");print $2,$3}'
}
SCHEMA="org.compiz.core:/org/compiz/profiles/unity/plugins/core/"
read screen_width screen_depth <<< "$(get_screen_geometry)"
hsize=$(gsettings get $SCHEMA hsize)
vsize=$(gsettings get $SCHEMA vsize)
declare -a viewports
y=0
for vertical in $(seq 1 $vsize); do
x=0
for horizontal in $(seq 1 $hsize); do
viewports+=( $( echo $y:$x ) )
x=$(($x+$screen_width))
done
y=$(($y+$screen_depth))
done
i=1
while [ $i -le ${#viewports[@]} ];
do
echo "Viewport $i is ${viewports[$(($i-1))]}"
i=$(($i+1))
done
$> bash viewports.sh
Viewport 1 is 0:0
Viewport 2 is 0:1366
Viewport 3 is 0:2732
Viewport 4 is 768:0
Viewport 5 is 768:1366
Viewport 6 is 768:2732
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment