for counting open windows I got
Code: Select all
wmctrl -l | wc -l
Code: Select all
who | awk 'END{print NR - 1}'
Any ideas?
Code: Select all
wmctrl -l | wc -l
Code: Select all
who | awk 'END{print NR - 1}'
My formula has to be:wmctrl -l
0x00c0000a 0 puppypc# sam. 13 jan. 18
0x00e00005 0 puppypc # xload
0x02600001 -1 puppypc # Conky (puppypc #)
0x02800001 -1 puppypc # Conky (puppypc #)
0x02a00001 -1 puppypc # Conky (puppypc #)
0x02c00001 -1 puppypc # Conky (puppypc #)
0x01e00002 -1 N/A N/A
0x01c00015 0 puppypc # Puppy Linux Discussion Forum :: View topic - jwm 2.3.6 aerosnap - Opera
0x02400001 -1 puppypc # Conky (puppypc #)
0x03200006 2 puppypc # Console1
Code: Select all
wmctrl -l | grep -v Conky | wc -l
5
who?stemsee wrote:Code: Select all
who | awk 'END{print NR - 1}'
Code: Select all
wmctrl -l | grep -v "\-1"
Your version would work even better than best if it would get the screen dimension rightstemsee wrote:My version works best when each function is its own script.
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}'
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
Auto quads and halves would need to exclude conky, panels, some yad gui's ... seems to me it will be necessary to select which windows to include in halves/quads 'wmctrl -r :SELECT:' which will be just as troublesome as operating on four individual windows. Unless the highest four layers or last four accessed could be determined and used for the operation.musher0 wrote:Hehe. My wmctrl counts terms just fine. But it's also counting each and every Conky configuration !!!My formula has to be:wmctrl -l
0x00c0000a 0 puppypc# sam. 13 jan. 18
0x00e00005 0 puppypc # xload
0x02600001 -1 puppypc # Conky (puppypc #)
0x02800001 -1 puppypc # Conky (puppypc #)
0x02a00001 -1 puppypc # Conky (puppypc #)
0x02c00001 -1 puppypc # Conky (puppypc #)
0x01e00002 -1 N/A N/A
0x01c00015 0 puppypc # Puppy Linux Discussion Forum :: View topic - jwm 2.3.6 aerosnap - Opera
0x02400001 -1 puppypc # Conky (puppypc #)
0x03200006 2 puppypc # Console1Don't ask me what that sticky "N/A" program is !!! Hm. It has to beCode: Select all
wmctrl -l | grep -v Conky | wc -l 5
bmpanel2. I have no merit, xwininfo sort of told me!!!
BFN.
if we impose a certain size to all windows. To be tested. It may look awful!wmctrl -i -r $line -e 0,$A,$B,0,0
Code: Select all
#!/bin/sh
# paves.sh # Quatre ou cinq fenêtres en pavés.
# Utilise : / Uses: wmctrl, awk, wc
# © Christian L'Écuyer, Gatineau (Qc), Canada, 1er sept. 2017. GPL3
# (alias musher0 [forum Puppy]) # https://opensource.org/licenses/GPL-3.0
#################### # Rev. : 14 janv. 2018.
# This program is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
##########
# Ce programme est libre : vous pouvez le redistribuer ou modifier selon les termes
# de la Licence Publique Générale GNU publiée par la Free Software Foundation (v. 3
# ou toute version ultérieure choisie par vous).
# Ce programme est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE
# GARANTIE, ni explicite ni implicite, y compris des garanties de commercialisation
# ou d'adaptation à un but spécifique. Pour plus de détails, veuillez vous reporter
# au texte officiel de cette licence à https://opensource.org/licenses/GPL-3.0, à
# http://www.linux-france.org/article/these/gpl.html pour une traduction et, pour une
# explication en français, à https://fr.wikipedia.org/wiki/Licence_publique_générale_GNU.
#################### set -xe
Bur="`wmctrl -d | awk '$2 ~/\*/ { print $1 }'`"
wmctrl -l | awk '$2 ~ /'"$Bur"'/ && $4 !~ /Conky|stalonetray|jar|exe|N\/A/ { print $1 }' > /tmp/fen
# Ne pas utiliser sur une fenêtre contrôlée par java, DOSBOX ou Wine, ou sur Conky.
awk '0 == NR % 2' /tmp/fen > /tmp/fen-paires # even lines
awk '0 == NR % 2' /tmp/fen-paires > /tmp/fen-paires-bas # bottom
awk '0 == (NR + 1) % 2' /tmp/fen-paires > /tmp/fen-paires-haut # top
awk '0 == (NR + 1) % 2' /tmp/fen > /tmp/fen-impaires # odd lines
awk '0 == NR % 2' /tmp/fen-impaires > /tmp/fen-impaires-bas # bottom
awk '0 == (NR + 1) % 2' /tmp/fen-impaires > /tmp/fen-impaires-haut # top
DemiHauteur="`xwininfo -root | awk '$1 ~ /Height/ { print $2/2 }'`" # Half height of screen
DemiLargeur="`xwininfo -root | awk '$1 ~ /Width/ { print $2/2 }'`" # Half width of screen
Valid="";Valid="`wc -l < /tmp/fen-paires-haut `"
if [ "$Valid" -gt "0" ];then
A=72;B=48
line="";while read line;do
wmctrl -i -r $line -e 0,$A,$B,0,0 2>/dev/null &
B="`expr $B + 100`"
done < /tmp/fen-paires-haut
fi
Valid="";Valid="`wc -l < /tmp/fen-impaires-haut `"
if [ "$Valid" -gt "0" ];then
C="`expr $DemiLargeur - 48`"
D=96
line="";while read line;do
wmctrl -i -r $line -e 0,$C,$D,0,0 2>/dev/null &
D="`expr $D + 100`"
done < /tmp/fen-impaires-haut
fi
A="";B="";C="";D="" # Ré-init.
Valid="";Valid="`wc -l < /tmp/fen-paires-bas `"
if [ "$Valid" -gt "0" ];then
A=72;B="$DemiHauteur"
line="";while read line;do
wmctrl -i -r $line -e 0,$A,$B,0,0 2>/dev/null &
B="`expr $B + 100`"
done < /tmp/fen-paires-bas
fi
Valid="";Valid="`wc -l < /tmp/fen-impaires-bas `"
if [ "$Valid" -gt "0" ];then
C="`expr $DemiLargeur - 48`"
D="$DemiHauteur" # 96
line="";while read line;do
wmctrl -i -r $line -e 0,$C,$D,0,0 2>/dev/null &
D="`expr $D + 100`"
done < /tmp/fen-impaires-bas
fi
rm -f /tmp/fen* # Nettoyage | Cleanup # set +xe