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 Sun 19 Jan 2020, 06:56
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
How to make jwm or wmctrl resize browser window?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
tallboy


Joined: 21 Sep 2010
Posts: 1598
Location: Drøbak, Norway

PostPosted: Tue 29 Aug 2017, 22:35    Post subject:  How to make jwm or wmctrl resize browser window?  

With great help from MochiMoppel, I made my Palemoon browser open, and also take focus, in virtual desktop 4, using wmctrl:
Browser open in virtual desktop 4, how to move focus too?.
My old 15" Dell monitor gave up a few days ago, and I was fortunate to pick up for free an HP 22" wide-screen monitor. I am not used to wide-screen, and I don't like the browser window to fill the entire screen. So, I try to make it open in a spesific screen, position and size, thus keeping my desktop icons visible.
My script palemon-4 opens the browser: (wmctrl counts from 0)
Code:
#!/bin/bash
wmctrl -s 3; exec /usr/bin/palemoon "$@"

I can also resize the browser window with this command in a terminal:
Code:
# wmctrl -r Pale Moon -e 8,270,88,1200,910

But I have 2 problems:
1) I would like the browser window to open in v.d.4, resize/reposition and take focus, but I am not capable of including the command in the script, and make it work! Sad
2) If I open a new regular or private window from the browser menu, the command will not resize the new window, not even from a new terminal. Is that because it is a child window?
BTW, the main and child window share the PID, but using wmctrl -i -r plus the PID, doesn't work for either window.

Can someone please suggest a solution?

Edit: There is one solution for a command using the :SELECT: option, where there is a pause which let you click on the window that is to be resized, it works on child windows, but only as a separate command.
Code:
# wmctrl -r :SELECT: -e 0,270,88,1200,910
When I make a script paleselect of that and pipe the original script into it, I can open a new window and click on it to reposition and resize it. But as long as it only works on new windows, it is only a half solution.
Code:
#!/bin/bash
wmctrl -s 3; exec /usr/bin/palemoon "$@" | paleselect

tallboy

Last edited by tallboy on Wed 30 Aug 2017, 01:46; edited 2 times in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1966
Location: Japan

PostPosted: Wed 30 Aug 2017, 00:40    Post subject:  

Try
Code:
#!/bin/bash
wmctrl -s 3
exec /usr/bin/palemoon "$@" &
sleep 3
wmctrl -r "Pale Moon" -e 8,270,88,1200,910

Note the '&' and the quotes around "Pale Moon".
As the browser needs some time to "settle" the sleep command is necessary before you start the resizing. 3 seconds works fine here but you may need a different timing.

When you open a new window from the browser the size will be the same as the resized original window.
Your terminal command does not resize the 2nd window as wmctrl will search for a window matching "Pale Moon" in the title, and the first it will find will always be the original window (lower window ID)
Back to top
View user's profile Send private message 
tallboy


Joined: 21 Sep 2010
Posts: 1598
Location: Drøbak, Norway

PostPosted: Wed 30 Aug 2017, 00:42    Post subject:  

Thank you Mochi, I'll try it out..
BTW, I added something to my post at the same time you posted.

tallboy

_________________
True freedom is a live Puppy on a multisession CD/DVD.
Back to top
View user's profile Send private message 
tallboy


Joined: 21 Sep 2010
Posts: 1598
Location: Drøbak, Norway

PostPosted: Wed 30 Aug 2017, 01:05    Post subject:  

That work very well, Mochi, thank you. I can actually get away with 2 seconds sleep.

By using the last script in my post with the :SELECT: option, it will work on all new windows, but not children.

I also saw that JWM 2.3.7 has some new options in Rule Settings, with initial geometry settings for windows, but I don't know if I can use the latest JWM in my Lucid 5.2.8.7, and I don't know if they'll work!

Why the "Pale Moon" in quotes? wmctrl also works with just pale.

tallboy

_________________
True freedom is a live Puppy on a multisession CD/DVD.
Back to top
View user's profile Send private message 
tallboy


Joined: 21 Sep 2010
Posts: 1598
Location: Drøbak, Norway

PostPosted: Wed 30 Aug 2017, 01:17    Post subject:  

Another path to a solution may be extracting the window ID from wmctrl -lp, a new window will be the last one listed, but how to make a script that interprets the making of a new window from the browser's menu, is way beyond me! Laughing

tallboy

_________________
True freedom is a live Puppy on a multisession CD/DVD.
Back to top
View user's profile Send private message 
musher0

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

PostPosted: Wed 30 Aug 2017, 01:21    Post subject:  

Hi tallboy.

The following will resize any window to 4/8 th's of your screen.

It is based on wmctrl's functions SELECT and ACTIVE.

The SELECT function brings a cross-hair on screen. With it you select the
window you wish to resize. The ACTIVE function does the job.

I used ACTIVE twice in this script because I found that it was necessary at
times to "insist" to get the result you want. You may wish to re-check this.

As the file name implies, this script is part of a series of scripts that can
resize a window from 1/8 to 7/8 of your monitor's dimensions. Just play
around with the fractions on the Height and Width lines -- or use another
denominator that suits you.

The code really tells it all! Wink If you need precisions, just ask me.

IHTH. BFN.

~~~~~~~~~~~~~
Code:
#!/bin/sh
# fractions_4-8.sh # To resize an application window
# © Christian L'Écuyer, Gatineau (Qc), Canada, Aug. 30 2017. GPL3
# (alias musher0 [forum Puppy]). https://opensource.org/licenses/GPL-3.0
#################   
#
#    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/>.
#
##########
Hauteur="`xwininfo -root | awk '$1 ~ /Height/ { print $2/2 }'`"
Largeur="`xwininfo -root | awk '$1 ~ /Width/ { print $2/2 }'`"

Y="`xwininfo -root | awk '$1 ~ /Height/ { print $2/8 }'`" # Anchor points
X="`xwininfo -root | awk '$1 ~ /Width/ { print $2/8 }'`" # on monitor.

wmctrl -r :SELECT: -e 0,$X,$Y,$Largeur,$Hauteur

# For most windows you need to "insist".
sleep 0.34s
wmctrl -r :ACTIVE: -e 0,$X,$Y,$Largeur,$Hauteur
# & # Do not use the ampersand, it makes the window go a bit nuts.
sleep 0.34s
wmctrl -r :ACTIVE: -e 0,$X,$Y,$Largeur,$Hauteur
#
# NOTE -- Do not use on a window controlled by java, DOSBOX or Wine.

_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
tallboy


Joined: 21 Sep 2010
Posts: 1598
Location: Drøbak, Norway

PostPosted: Wed 30 Aug 2017, 01:36    Post subject:  

Thank you, Musher0.
Quote:
I used ACTIVE twice in this script because I found that it was necessary at times to "insist" to get the result you want. You may wish to re-check this.
The sleep command fixed that.

I now have two solutions to make a new window appear on dt 4, be repositoned, resized and take focus. I usually open new tabs, but I sometimes use a private window, and it seems I will have to use a separate command to place that window on top of the existing.(or somewhere else)

tallboy
window.jpg
 Description   
 Filesize   39.04 KB
 Viewed   141 Time(s)

window.jpg


_________________
True freedom is a live Puppy on a multisession CD/DVD.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1966
Location: Japan

PostPosted: Wed 30 Aug 2017, 03:14    Post subject:  

tallboy wrote:
Why the "Pale Moon" in quotes? wmctrl also works with just pale.
Because "Pale Moon" is 1 string and Pale Moon are 2 strings. Wmtrl ignores the 2nd string, so would search only for Pale. In my case found a ROX-Filer window /tmp/palemoon on a different desktop and resized it. The less precise you define the match string the greater your chances that wmctrl finds the wrong window.

If you want to (partly) match the title you could use the more precise
Code:
wmctrl -r " - Pale Moon" -e 8,270,88,1200,910
Hard to believe that any other window except the browser window would match.

Another option is to use the WM_CLASS property:
Code:
wmctrl -xr "Pale moon" -e 8,270,88,1200,910
Will match only windows of the Pale Moon browser

or even more precise
Code:
wmctrl -xr "Navigator" -e 8,270,88,1200,910
Will match only main windows of the Pale Moon browser, but not the initial window "Pale Moon is not currently set as your default browser".
Back to top
View user's profile Send private message 
tallboy


Joined: 21 Sep 2010
Posts: 1598
Location: Drøbak, Norway

PostPosted: Wed 30 Aug 2017, 03:49    Post subject:  

Thank you, Mochi, that is very interesting.
I think I will use this script for now:
Code:
#!/bin/bash
wmctrl -s 3; exec /usr/bin/palemoon "$@" | wmctrl -r :SELECT: -e 0,270,88,1200,910

That way all new windows get intentionally selected and repositioned/resized. Can I catch the children with a deamon?

Have you seen the latest JWM options that I mentioned above?

tallboy

_________________
True freedom is a live Puppy on a multisession CD/DVD.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
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.0485s ][ Queries: 12 (0.0044s) ][ GZIP on ]