As usual I found this code online, I am not qualified to assess it, but when i type it in terminal or invoke it from a script and compare it with the number of apparent windows open on my desktop it seemed more accurate than other methods invoking 'ls /dev/pts'MochiMoppel wrote:who?stemsee wrote:Code: Select all
who | awk 'END{print NR - 1}'
So if it works in most situations, that'll do for me.
thanks!
Here is MM (middle screen by thirds)
Code: Select all
#!/bin/sh
res=`xwininfo -root | grep -e 'Height' -e 'Width' | awk '{print $2}'`
XX=`echo $res | awk '{print $1}'`
YY=`echo $res | awk '{print $2}'`
XX=$((XX / 3))
YY=$((YY))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
if [[ ! -e /tmp/MR && ! -e /tmp/RM ]]; then
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
touch /tmp/MR
elif [[ -e /tmp/MR ]]; then
YY=$((YY / 3))
rm -f /tmp/MR
wmctrl -r :ACTIVE: -e 0,$XX,$YY,$XX,$YY
touch /tmp/RM
elif [[ -e /tmp/RM ]]; then
XX=`echo $res | awk '{print $1}'`
YY=`echo $res | awk '{print $2}'`
XX=$((XX / 3))
YY=$((YY / 3))
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
rm /tmp/RM
fi