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 02 Aug 2015, 14:39
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
JWM: How to quickly display 2 windows side-by-side
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [12 Posts]  
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 731
Location: Japan

PostPosted: Sun 01 Mar 2015, 00:43    Post subject:  JWM: How to quickly display 2 windows side-by-side
Subject description: Keyboard shortcuts to snap windows to screen edges
 

A user made a request to mimic the AeroSnap function of Windows 7 with JWM. I don't know if it is useful for anyone else, but I gave it a shot.
AeroSnap lets you quickly snap a window to any of the 4 screen edges, resizing it to half of screen size. This makes it easy to display 2 windows side-by-side.

The following steps will add 4 keyboard shortcuts Ctrl+Alt+Left/Top/Right/Down to JWM's configuration. The code requires wmctrl to be installed. Please note that the windows will be horizontally or vertically maximized. This allows to restore them (approximately!) to their previous size.

Step 1: Open file /root/.jwm/jwmrc-personal with an editor
Step 2: Insert following 4 shortcuts (If your browser shows more than 4 lines: copy the whole code section to your editor. This will eliminate any confusing line wraps and you should end up with only 4 lines)
Step 3: Save jwmrc-personal
Step 4: Restart JWM (Menu: Shutdown > Restart JWM or from Terminal: jwm -restart)

Code:
<Key mask="AC" key="Left"> exec:SW=$(($(cat /tmp/pup_event_frontend_scrn_x)/2));wmctrl -r :ACTIVE: -e 0,0,-1,$SW,-1;  wmctrl -r :ACTIVE: -b add,maximized_vert</Key>
<Key mask="AC" key="Right">exec:SW=$(($(cat /tmp/pup_event_frontend_scrn_x)/2));wmctrl -r :ACTIVE: -e 0,$SW,-1,$SW,-1;wmctrl -r :ACTIVE: -b add,maximized_vert</Key>
<Key mask="AC" key="Up">   exec:SH=$(($(cat /tmp/pup_event_frontend_scrn_y)/2));wmctrl -r :ACTIVE: -e 0,-1,0,-1,$SH;  wmctrl -r :ACTIVE: -b add,maximized_horz</Key>
<Key mask="AC" key="Down"> exec:SH=$(($(cat /tmp/pup_event_frontend_scrn_y)/2));wmctrl -r :ACTIVE: -e 0,-1,$SH,-1,$SH;wmctrl -r :ACTIVE: -b add,maximized_horz</Key>

That's all.

IMPORTANT UPDATE 2015-05-16
JWM v.2.3 adds new configuration options and key bindings: maxh, maxv, maxtop, maxbottom, maxleft and maxright.
This not only makes above wmctrl work around obsolete, it provides much faster and reliable tiling. Above shortcuts would look like this:
Code:
<Key mask="AC" key="Left">maxleft</Key>
<Key mask="AC" key="Right">maxright</Key>
<Key mask="AC" key="Up">maxtop</Key>
<Key mask="AC" key="Down">maxbottom</Key>

Tested with the currently newest snapshot 1102 Looks perfect. Screen orientation observed, trays observed and window size/position correctly restored to pre-tiling settings.

Last edited by MochiMoppel on Sat 16 May 2015, 03:11; edited 1 time in total
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2964
Location: www.eussenheim.de/

PostPosted: Sun 01 Mar 2015, 06:35    Post subject: Re: JWM: How to quickly display 2 windows side-by-side
Subject description: Keyboard shortcuts to snap windows to screen edges
 

Gave it a shot in Puppy Precise 5.7.1
Works like a charm.
Thank you.
side-by-side.png
 Description   
 Filesize   49.4 KB
 Viewed   741 Time(s)

side-by-side.png

Back to top
View user's profile Send private message 
recobayu


Joined: 15 Sep 2010
Posts: 145
Location: indonesia

PostPosted: Sun 01 Mar 2015, 13:55    Post subject:  

Great! Finally, someone use this method. Thanks Mochi. Your script is very very simple. Ohya, in the new jwm like Tahrpup, the windows key is work nice. So we can change
Code:
<Key mask="AC" key="Left">

by
Code:
<Key mask="4" key="Left">

then we can control window position by win + arrow. Wink just like cinnamon and wdz10 did.
I'm so sorry about your personal jwmrc. Crying or Very sad
I think usually I install a new pet comes from this universe into a 'prefix = ram' puppy.
Back to top
View user's profile Send private message 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 949
Location: nyc

PostPosted: Sun 01 Mar 2015, 23:29    Post subject: Re: JWM: How to quickly display 2 windows side-by-side
Subject description: Keyboard shortcuts to snap windows to screen edges
 

MochiMoppel wrote:
A user made a request to mimic the AeroSnap function of Windows 7 with JWM. I don't know if it is useful for anyone else, but I gave it a shot.
AeroSnap lets you quickly snap a window to any of the 4 screen edges, resizing it to half of screen size. This makes it easy to display 2 windows side-by-side.

The following steps will add 4 keyboard shortcuts Ctrl+Alt+Left/Top/Right/Down to JWM's configuration. The code requires wmctrl to be installed. Please note that the windows will be horizontally or vertically maximized. This allows to restore them (approximately!) to their previous size.

Step 1: Open file /root/.jwm/jwmrc-personal with an editor
Step 2: Insert following 4 red lines (If your browser shows more than 4 lines: copy the whole red section to your editor. This will eliminate any confusing line wraps and you should end up with only 4 lines)
Step 3: Save jwmrc-personal
Step 4: Restart JWM (Menu: Shutdown > Restart JWM or from Terminal: jwm -restart)

<Key keycode="236">exec:defaultbrowser</Key>
<Key keycode="111">exec:tas</Key>


<Key mask="AC" key="Left"> exec:SW=$(($(cat /tmp/pup_event_frontend_scrn_x)/2));wmctrl -r :ACTIVE: -e 0,0,-1,$SW,-1; wmctrl -r :ACTIVE: -b add,maximized_vert</Key>
<Key mask="AC" key="Right">exec:SW=$(($(cat /tmp/pup_event_frontend_scrn_x)/2));wmctrl -r :ACTIVE: -e 0,$SW,-1,$SW,-1;wmctrl -r :ACTIVE: -b add,maximized_vert</Key>
<Key mask="AC" key="Up"> exec:SH=$(($(cat /tmp/pup_event_frontend_scrn_y)/2));wmctrl -r :ACTIVE: -e 0,-1,0,-1,$SH; wmctrl -r :ACTIVE: -b add,maximized_horz</Key>
<Key mask="AC" key="Down"> exec:SH=$(($(cat /tmp/pup_event_frontend_scrn_y)/2));wmctrl -r :ACTIVE: -e 0,-1,$SH,-1,$SH;wmctrl -r :ACTIVE: -b add,maximized_horz</Key>

</JWM>

That's all.


this is potentially much nicer, neater, and more convenient than what i have, that i already have it notwithstanding.
Very Happy

Mochi, how can i get wmctrl to work on a specific screen/monitor, or more directly to the point, how can your code be adapted to work on the second, or third (etc) monitor? i can't find the part of puppy that identifies each screen as an individual entity--i thought your "pup_event_frontend_scrn_y" might be the clue i needed, but--if it is, i still don't get it.
Confused


and not something i'm interested in, but since it's come up before--do you know what would make a dragged window snap to a given edge like the OP was requesting? i know ETP had something like that--is it a mouse thing or a move onto script thing or... just curious and in case it comes up again.

also, thanks in advance and thanks once again for the nearly countless tweaks you've helped me make to my setups.
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 359

PostPosted: Wed 04 Mar 2015, 16:25    Post subject:  

On Windows I'm addicted to a autohotkey script that uses a clever combination of keys to resize and position the active window: CAPS LOCK followed by a letter key. I don't know, I'm asking now: can linux use CAPS+letter instead of Ctrl/Win/Shift/Alt combinations?

If you're curious, the autohotkey script is pretty smart. CAPSLOCK+a resizes the active window to half screen width and snaps it to the left edge of the screen. CAPSLOCK+d does the same to the right edge. CAPSLOCK+d followed again by CAPSLOCK+d reduces to 1/4 screen width and snaps to right edge. CAPSLOCK+w snaps to top. CAPS+x to bottom. CAPS+s to screen center. Repeatedly pressing the same key combo cycles through predefined sizes: 1/2, 1/4, 3/4. And letters a,d,w,x, and s form a cross by the CAPS key. Very visual, easy to remember.

_________________
Fatdog64-700|+Packages|find-n-run|Blue Pup 4|DebianDog+OpenMediaVault
Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 3194
Location: New Zealand

PostPosted: Thu 05 Mar 2015, 03:11    Post subject:  

step wrote:
And letters a,d,w,x, and s form a cross by the CAPS key. Very visual, easy to remember.
If anyone gets this going I'd love to see it using caps+arrows rather than caps+letter.

The arrow functions would be more visual for me than adwsx (which is admittedly visual but easily forgotten by my brain...
Back to top
View user's profile Send private message 
hapless_user

Joined: 20 Feb 2015
Posts: 10

PostPosted: Mon 30 Mar 2015, 12:58    Post subject:  

Thanks,MochiMoppel! Simply solves the annoyance of windows overlap!
Back to top
View user's profile Send private message 
unL33T

Joined: 09 May 2015
Posts: 8

PostPosted: Sat 09 May 2015, 20:26    Post subject:  

For some reason only Left and Up are working for me. Using Right or Down does the same and Left and Up respectively.

Any suggestions?

Edit: Nevermind, I found there is different behaviour depending on whether I have already used this shortcut on a window or not. For example, if I use the shortcut to push it to the right of the screen and then try to push it to the left, it doesn't work. Wonder why. But on a newly opened window, any of the shortcuts will work. Guessing it has something to do with how the hotkey script interacts with the window manager?
Back to top
View user's profile Send private message 
recobayu


Joined: 15 Sep 2010
Posts: 145
Location: indonesia

PostPosted: Sun 10 May 2015, 22:56    Post subject:  

unL33T,
try here, stickyjwm2.pet:
http://murga-linux.com/puppy/viewtopic.php?p=834071#834071
Smile
Back to top
View user's profile Send private message 
unL33T

Joined: 09 May 2015
Posts: 8

PostPosted: Mon 11 May 2015, 18:20    Post subject:  

recobayu wrote:
unL33T,
try here, stickyjwm2.pet:
http://murga-linux.com/puppy/viewtopic.php?p=834071#834071
Smile
Awesome! Thanks!

Is there a way I can use my Windows key (Super_L) as a hotkey while also using it as a mask?

I'd like to be able to use it to open the menu (ideally also from the bottom left corner) while maintaining it's use as a mask for these window shortcuts and a few others I have set up to mimic the behaviour of Windows.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 731
Location: Japan

PostPosted: Mon 11 May 2015, 21:43    Post subject:  

unL33T wrote:
if I use the shortcut to push it to the right of the screen and then try to push it to the left, it doesn't work. Wonder why. But on a newly opened window, any of the shortcuts will work. Guessing it has something to do with how the hotkey script interacts with the window manager?
Probably. I tried to keep the code as short as possible, but this may have pushed the wm to its limits. Checking my own implementation I notice that I added a step to clear the maximized status of a window before changing back to normal size. Can't remember why I did it (my original code works for me), but it could well be that I faced the same issues as you did in some distributions.

This is basically what I use now. Maybe you can kindly try it and report back if it solves your issue:
Code:
<Key mask="AC" key="Left"> exec:
   SW=$(($(xwininfo -root|awk '$1=="Width:"{print $2}')/2))
   wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
   wmctrl -r :ACTIVE: -e 0,0,-1,$SW,-1
   wmctrl -r :ACTIVE: -b add,maximized_vert
</Key>
<Key mask="AC" key="Right">exec:
   SW=$(($(xwininfo -root|awk '$1=="Width:"{print $2}')/2))
   wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
   wmctrl -r :ACTIVE: -e 0,$SW,-1,$SW,-1
   wmctrl -r :ACTIVE: -b add,maximized_vert
</Key>
<Key mask="AC" key="Up"> exec:
   SH=$(($(xwininfo -root|awk '$1=="Height:"{print $2}')/2))
   wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
   wmctrl -r :ACTIVE: -e 0,-1,0,-1,$SH
   wmctrl -r :ACTIVE: -b add,maximized_horz
</Key>
<Key mask="AC" key="Down"> exec:
   SH=$(($(xwininfo -root|awk '$1=="Height:"{print $2}')/2))
   wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
   wmctrl -r :ACTIVE: -e 0,-1,$SH,-1,$SH
   wmctrl -r :ACTIVE: -b add,maximized_horz
</Key>


As for the Windows key: You can use it as a modifier key or a normal key, but both? How should this possibly work? You can however use different assignments for left and right Windows keys.
Back to top
View user's profile Send private message 
unL33T

Joined: 09 May 2015
Posts: 8

PostPosted: Tue 12 May 2015, 20:16    Post subject:  

MochiMoppel wrote:
unL33T wrote:
if I use the shortcut to push it to the right of the screen and then try to push it to the left, it doesn't work. Wonder why. But on a newly opened window, any of the shortcuts will work. Guessing it has something to do with how the hotkey script interacts with the window manager?
Probably. I tried to keep the code as short as possible, but this may have pushed the wm to its limits. Checking my own implementation I notice that I added a step to clear the maximized status of a window before changing back to normal size. Can't remember why I did it (my original code works for me), but it could well be that I faced the same issues as you did in some distributions.

This is basically what I use now. Maybe you can kindly try it and report back if it solves your issue:
Code:
<Key mask="AC" key="Left"> exec:
   SW=$(($(xwininfo -root|awk '$1=="Width:"{print $2}')/2))
   wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
   wmctrl -r :ACTIVE: -e 0,0,-1,$SW,-1
   wmctrl -r :ACTIVE: -b add,maximized_vert
</Key>
<Key mask="AC" key="Right">exec:
   SW=$(($(xwininfo -root|awk '$1=="Width:"{print $2}')/2))
   wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
   wmctrl -r :ACTIVE: -e 0,$SW,-1,$SW,-1
   wmctrl -r :ACTIVE: -b add,maximized_vert
</Key>
<Key mask="AC" key="Up"> exec:
   SH=$(($(xwininfo -root|awk '$1=="Height:"{print $2}')/2))
   wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
   wmctrl -r :ACTIVE: -e 0,-1,0,-1,$SH
   wmctrl -r :ACTIVE: -b add,maximized_horz
</Key>
<Key mask="AC" key="Down"> exec:
   SH=$(($(xwininfo -root|awk '$1=="Height:"{print $2}')/2))
   wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
   wmctrl -r :ACTIVE: -e 0,-1,$SH,-1,$SH
   wmctrl -r :ACTIVE: -b add,maximized_horz
</Key>


As for the Windows key: You can use it as a modifier key or a normal key, but both? How should this possibly work? You can however use different assignments for left and right Windows keys.
The second version that was posted above already resolved my problem. Thanks, though. Smile

It works in Windows (single press of the Win key brings up Start Menu, Win + other keys are many shortcuts [show desktop, run, open explorer, etc]) but I agree, it is hard to implement in JWM, it seems. No matter what I try I end up with just the menu opening.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [12 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
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.1899s ][ Queries: 12 (0.0308s) ][ GZIP on ]