Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 19 Jun 2018, 04:13
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Desktop
jwm 2.3.6 aerosnap
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [29 Posts]   Goto page: Previous 1, 2
Author Message
stemsee

Joined: 27 Jun 2013
Posts: 2203
Location: In The Way

PostPosted: Sat 13 Jan 2018, 17:02    Post subject:  

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:
wmctrl -l | wc -l

for terms
Code:
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?
Back to top
View user's profile Send private message MSN Messenger 
musher0


Joined: 04 Jan 2009
Posts: 12314
Location: Gatineau (Qc), Canada

PostPosted: Sat 13 Jan 2018, 18:15    Post subject:  

Hehe. My wmctrl counts terms just fine. But it's also counting each and every Conky configuration !!!
Quote:
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:
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
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1536
Location: Japan

PostPosted: Sat 13 Jan 2018, 22:06    Post subject:  

stemsee wrote:
Code:
who | awk 'END{print NR - 1}'
who?
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 12314
Location: Gatineau (Qc), Canada

PostPosted: Sat 13 Jan 2018, 23:49    Post subject:  

I have never heard of this person!!! Laughing Wink

~~~~~~~~~
Seriously, back to the formula, this one is much better, in that it skips all the stickies:
Code:
wmctrl -l | grep -v "\-1"

BFN.

_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1536
Location: Japan

PostPosted: Sun 14 Jan 2018, 02:50    Post subject:  

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 Laughing ) those using xrandr are the slowest.
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2203
Location: In The Way

PostPosted: Sun 14 Jan 2018, 07:03    Post subject:  

MochiMoppel wrote:
stemsee wrote:
Code:
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:
#!/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
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2203
Location: In The Way

PostPosted: Sun 14 Jan 2018, 11:00    Post subject:  

musher0 wrote:
Hehe. My wmctrl counts terms just fine. But it's also counting each and every Conky configuration !!!
Quote:
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:
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.
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2203
Location: In The Way

PostPosted: Sun 14 Jan 2018, 12:23    Post subject:  

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

Manual quads, how long does it take?
out_2018-01-14_155039.mp4.gz
Description 
gz

 Download 
Filename  out_2018-01-14_155039.mp4.gz 
Filesize  201.58 KB 
Downloaded  61 Time(s) 
Back to top
View user's profile Send private message MSN Messenger 
musher0


Joined: 04 Jan 2009
Posts: 12314
Location: Gatineau (Qc), Canada

PostPosted: Sun 14 Jan 2018, 23:30    Post subject:  

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:
Quote:
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! Smile

BFN.
~~~~~~~~~~~~
Code:
#!/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
paves.sh.jpg
Description  The little window in the middle is waimea's "Window List". 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.
jpg

 Download 
Filename  paves.sh.jpg 
Filesize  232.75 KB 
Downloaded  67 Time(s) 

_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)

Last edited by musher0 on Mon 15 Jan 2018, 02:04; edited 1 time in total
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 12314
Location: Gatineau (Qc), Canada

PostPosted: Mon 15 Jan 2018, 00:22    Post subject:  

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.
paves2.sh-2.jpg
 Description   
 Filesize   119.22 KB
 Viewed   125 Time(s)

paves2.sh-2.jpg

paves2.zip
Description  Unzip in an "bin" path and make executable.
zip

 Download 
Filename  paves2.zip 
Filesize  1.66 KB 
Downloaded  45 Time(s) 
paves2.sh.jpg
 Description   
 Filesize   114.05 KB
 Viewed   128 Time(s)

paves2.sh.jpg


_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 12314
Location: Gatineau (Qc), Canada

PostPosted: Mon 15 Jan 2018, 02:03    Post subject:  

Offshoot here.
_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2203
Location: In The Way

PostPosted: Mon 15 Jan 2018, 08:38    Post subject:  

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.
Back to top
View user's profile Send private message MSN Messenger 
musher0


Joined: 04 Jan 2009
Posts: 12314
Location: Gatineau (Qc), Canada

PostPosted: Mon 15 Jan 2018, 08:46    Post subject:  

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? Wink Wink

BFN.

_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2203
Location: In The Way

PostPosted: Mon 15 Jan 2018, 10:31    Post subject:  

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!
Back to top
View user's profile Send private message MSN Messenger 
Display posts from previous:   Sort by:   
Page 2 of 2 [29 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Desktop
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2028s ][ Queries: 14 (0.0443s) ][ GZIP on ]