jwm 2.3.6 aerosnap

Window managers, icon programs, widgets, etc.
Message
Author
stemsee

#16 Post by stemsee »

So I was trying to script quads and halves but there seems to be no reliable way to count open windows.

for counting open windows I got

Code: Select all

wmctrl -l | wc -l
for terms

Code: Select all

who | awk 'END{print NR - 1}'
Problem is that Geany is counted in both cases. But terms are counted only in the later case. So use code and exclude term in window manipulations, or include geany in both manipulation strategies? One for non-terms and one for terms.

Any ideas?

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#17 Post by musher0 »

Hehe. My wmctrl counts terms just fine. But it's also counting each and every Conky configuration !!!
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
My formula has to be:

Code: Select all

wmctrl -l | grep -v Conky | wc -l
5
Don't ask me what that sticky "N/A" program is !!! Hm. It has to be
bmpanel2. I have no merit, xwininfo sort of told me!!!

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#18 Post by MochiMoppel »

stemsee wrote:

Code: Select all

who | awk 'END{print NR - 1}'
who?

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#19 Post by musher0 »

I have never heard of this person!!! :lol: ;)

~~~~~~~~~
Seriously, back to the formula, this one is much better, in that it skips all the stickies:

Code: Select all

wmctrl -l | grep -v "\-1"
BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#20 Post by MochiMoppel »

stemsee wrote:My version works best when each function is its own script.
Your version would work even better than best if it would get the screen dimension right :wink:
I remember a discusion with SFR about this problem (see here).

I also strongly recommend not to use xrandr for the job. In my private collection of code snippets that calculate screen dimension (28 by last count :lol: ) those using xrandr are the slowest.

stemsee

#21 Post by stemsee »

MochiMoppel wrote:
stemsee wrote:

Code: Select all

who | awk 'END{print NR - 1}'
who?
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'

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

stemsee

#22 Post by stemsee »

musher0 wrote:Hehe. My wmctrl counts terms just fine. But it's also counting each and every Conky configuration !!!
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
My formula has to be:

Code: Select all

wmctrl -l | grep -v Conky | wc -l
5
Don't ask me what that sticky "N/A" program is !!! Hm. It has to be
bmpanel2. I have no merit, xwininfo sort of told me!!!

BFN.
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.

stemsee

#23 Post by stemsee »

'Tile' works automatically ... but everything gets tiled - panels -conky etc - seems the maths is pre-HD too.

Manual quads, how long does it take?
Attachments
out_2018-01-14_155039.mp4.gz
(201.58 KiB) Downloaded 196 times

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#24 Post by musher0 »

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
Attachments
paves.sh.jpg
The little window in the middle is waimea's &quot;Window List&quot;. It is NOT placed there by this script. It is only there to show the list of programs. Also, I chopped about 1/10 of the right part, because of forum requirements on image size.
(232.75 KiB) Downloaded 188 times
Last edited by musher0 on Mon 15 Jan 2018, 06:04, edited 1 time in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#25 Post by musher0 »

Hello again all.

Here is a 2nd take already, with two positioning functions instead of repetitions of code.

I find the result of this version classier (please see attached pic) and its code, more
rational. But that's just me. Comments welcome.

BFN.
Attachments
paves2.sh-2.jpg
(119.22 KiB) Downloaded 193 times
paves2.zip
Unzip in an &quot;bin&quot; path and make executable.
(1.66 KiB) Downloaded 147 times
paves2.sh.jpg
(114.05 KiB) Downloaded 197 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#26 Post by musher0 »

musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

stemsee

#27 Post by stemsee »

I am using fatdog64-720 and paves2 script doesn't work here! No errors in term ... one window occasionally gets moved slightly!

Looks good though.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#28 Post by musher0 »

Hi Stemsee

-- Does that FatDog64 have a 64 bit version of wmctrl?

-- Does it have xwininfo? Some Pups do not.

-- 64-bits or 32-bits should not matter, since this is a bash script. The bash interpreter
has to be 64-bits on a 64-bits distro and 32-bits on a 32-bits distro, but it does not
matter for the script itself, it will run on whatever bash interpreter is there.

-- Am I talking to the same Stemsee who devised a script to compile Linux kernels
automatically? ;) ;)

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

stemsee

#29 Post by stemsee »

Yup it is!

I have wmctrl 64bit and xdotool and xwininfo. Nothing doing! But I will try it on a pristine fatdog install soon, just in case my savefile is corrupt!

Post Reply