Hello stemsee and all.
I may have found an awk solution for filtering out apps we do not want to tile. Also
about the quads. I divide the general list provided by wmctrl in four smaller lists:
top right, top-left, middle-left,middle-right, and I process those separately.
The result is NOT true tilling: in the quadrants, the windows are as a cascade.
I am rather satisfied with the results for now, although I can certainly see
improvements in the occupation of monitor space.
Another improvement should be focus: the smaller windows are covered by the
bigger ones, so the user has to rely on the task bar to know where is what.
That could perhaps be solved with the last two parameters on the wmctrl line:
wmctrl -i -r $line -e 0,$A,$B,0,0
if we impose a certain size to all windows. To be tested. It may look awful!
Finally, pardon my French! I may have forgotten to translate some comments.
If this is a problem, please ask, and I will provide a translation.
Have fun: do with it as you like!
BFN.
~~~~~~~~~~~~
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