You are not logged in.

#1 2015-10-10 07:28:47

tranjeeshan
Member
Registered: 2015-10-02
Posts: 69

[SOLVED] Window positioning with NUM Keypad in bunsenlabs (Openbox)

This is a cross-post from #! forums.

tranjeeshan wrote:

I don't know whether any Ubuntu Unity user is here, but Unity has a great feature of window positioning using Ctrl+Alt+Num(keypad). It sets the current window in the corresponding position in accordance with the pressed Num Key. I'll give the examples here:

Ctrl+Alt+1 would position the window in Bottom Left Corner
Ctrl+Alt+3 would position the window in Bottom Right Corner
Ctrl+Alt+9 would position the window in Top Right Corner
Ctrl+Alt+7 would position the window in Top Left Corner
Ctrl+Alt+2 would position the window in Bottom Half-of-the-Screen
Ctrl+Alt+8 would position the window in Top Half-of-the-Screen
Ctrl+Alt+4 would position the window in Left Half-of-the-Screen
Ctrl+Alt+6 would position the window in Right Half-of-the-Screen
Ctrl+Alt+5 would position the window in Center of the Screen in its Normal size

I want to implement 'exactly' this feature in my Openbox WM of bunsenlabs. How would I do that?


"Unix is simple. It just takes a genius to understand its simplicity."  - Dennis Ritchie (1941-2011), Unix Co-Creator
Unix philosophy

Offline

#2 2015-10-10 07:32:31

tranjeeshan
Member
Registered: 2015-10-02
Posts: 69

Re: [SOLVED] Window positioning with NUM Keypad in bunsenlabs (Openbox)

alaskan-hippie wrote:

This is the best I've been able to do with it. Works perfectly (almost) on a single monitor setup, but is a little buggy on dual monitor (see details below).

I'm going to explain this as if the reader is completely green, as step by step as I can think to make it.

So, to start out, open your rc.xml file (located in ~/.config/openbox/) in geany. There is a section in the file already that attempts to do some tiling (but isn't so great), which I commented out and placed my code next to. So go to "Find" (ctrl+f) and type "A bit of tiling" and you should get to the section I'm talking about (if you're using default rc.xml file, it'll be around line 429).

To make a comment, you would do this:

<!-- Text you want commented out -->

I would comment out the 'tiling' keybinds already there like so:

<!--     <keybind key="W-Right">
      <action name="GrowToEdgeEast"/>
    </keybind>
    <keybind key="W-Left">
      <action name="GrowToEdgeWest"/>
    </keybind>
    <keybind key="W-Down">
      <action name="GrowToEdgeSouth"/>
    </keybind>
    <keybind key="W-Up">
      <action name="GrowToEdgeNorth"/>
    </keybind>
    <keybind key="W-A-Left">
      <action name="Execute">
        <command>cb-aerosnap --left</command>
      </action>
    </keybind>
    <keybind key="W-A-Right">
      <action name="Execute">
        <command>cb-aerosnap --right</command>
      </action>
    </keybind>  -->

Then paste my code below underneath that:

<!-- Start of Tiling -->
<!-- Poorly strewn together by alaskan-hippie who can be found here: http://crunchbang.org/forums/profile.php?id=9401 -->

<!--Bottom Left-->
	<keybind key="W-A-KP_1">
		<action name="UnmaximizeFull"/>
		<action name="MoveResizeTo">
			<width>50%</width>
			<height>50%</height>
		</action>
		<action name="MoveToEdge"><direction>south</direction></action>
		<action name="MoveToEdge"><direction>west</direction></action>
	</keybind>
<!--Bottom-->
	<keybind key="W-A-KP_2">
		<action name="UnmaximizeFull"/>
		<action name="Maximize"><direction>horizontal</direction></action>
		<action name="MoveResizeTo">
			<height>50%</height>
		</action>
		<action name="MoveToEdge"><direction>south</direction></action>
	</keybind>
<!--Bottom Right-->	
	<keybind key="W-A-KP_3">
		<action name="UnmaximizeFull"/>
		<action name="MoveResizeTo">
			<width>50%</width>
			<height>50%</height>
		</action>
		<action name="MoveToEdge"><direction>south</direction></action>
		<action name="MoveToEdge"><direction>east</direction></action>
	</keybind>
<!--Full Left-->
	<keybind key="W-A-KP_4">
		<action name="UnmaximizeFull"/>
		<action name="MaximizeVert"/>
		<action name="MoveResizeTo">
			<width>50%</width>
		</action>
		<action name="MoveToEdge"><direction>west</direction></action>
	</keybind>
<!--Full Screen/Center-->
	<keybind key="W-A-KP_5">
		<action name="Maximize"><direction>both</direction></action>
	</keybind>
<!--Full Right-->
	<keybind key="W-A-KP_6">
		<action name="UnmaximizeFull"/>
		<action name="MaximizeVert"/>
		<action name="MoveResizeTo">
			<width>50%</width>
		</action>
		<action name="MoveToEdge"><direction>east</direction></action>
	</keybind>
<!--Top Left-->
	<keybind key="W-A-KP_7">
		<action name="UnmaximizeFull"/>
		<action name="MoveResizeTo">
			<width>50%</width>
			<height>50%</height>
		</action>
		<action name="MoveToEdge"><direction>north</direction></action>
		<action name="MoveToEdge"><direction>west</direction></action>
	</keybind>
<!--Full Top-->
	<keybind key="W-A-KP_8">
		<action name="UnmaximizeFull"/>
		<action name="Maximize"><direction>horizontal</direction></action>
		<action name="MoveResizeTo">
			<height>50%</height>
		</action>
		<action name="MoveToEdge"><direction>north</direction></action>
	</keybind>
<!--Top Right-->
	<keybind key="W-A-KP_9">
		<action name="UnmaximizeFull"/>
		<action name="MoveResizeTo">
			<width>50%</width>
			<height>50%</height>
		</action>
		<action name="MoveToEdge"><direction>north</direction></action>
		<action name="MoveToEdge"><direction>east</direction></action>
	</keybind>
		
<!-- End of tiling -->	

After that, save (ctrl+s) and then restart openbox by either pressing alt+F2 and typing "openbox --restart" or by going to the menu entry Settings -> Openbox -> Restart.

Now you should have your makeshift manual tiling. The keypad represents the screen, each number would be where the window will snap to (eg, super+alt+numpad_1 brings the window to the bottom left quarter of the screen), and the center (5) will maximize the window.

Details regarding single monitor setups:
Moving between certain positions you may have to press the desired key combo a times. I tested on my laptop and noticed that going from full left/right to top left/right would leave the window the right size but hanging in the middle top, and going from any top position to bottom would again resize correctly but leave the window floating a little ways up the screen. Both of those situations were fixed by hitting the key combo again.

Details regarding laptops:
Many laptops don't have full keypads, but rather keys mapped to both regular keyboard keys and numpad keys (ie, on my laptop U is also 4, if my numpad lock is on). I recommend changing them to the standard numbers, or to the arrow keys (I prefer the arrow keys). If changing to the arrow keys, consider short example below that I use myself.

<!-- Top Left-->
<keybind key="W-C-A-Up">
<!--Left-->
<keybind key="W-A-Left">
<!--Bottom Left-->
<keybind key="W-C-A-Left">
<!--Top Right-->
<keybind key="W-C-A-Right">
<!--Bottom Right-->
<keybind key="W-C-A-Down">

Details regarding dual monitor setups:
If you have two monitors side by side (using twinview or similar), the center line will likely be fuzzy from openbox's perspective. What this means is, if you have a full height half width window on the right side (ie full right) of your left monitor, and you go to make it full bottom, it'll probably split between the two monitors. This will also happen if you have a top/bottom right window on the left monitor and go to make it a full right. The only way I've found around this so is to bring the window to the opposite side of the screen from the center line between the monitors, then you can bring it back.

For example, say I have a window in the top left (position 7) of my right-most monitor that I would like to move to the bottom left (pos. 1) of the same monitor. If I was to try this out-right, it would move to the bottom left (pos. 1), but also be showing some (a little, or a lot) on the left monitor as well, which is not what I wanted. What I do to prevent that window from jumping over to the other screen is to bring it to the bottom right (pos. 3) first, then to the bottom left (pos. 1). It's a bit cumbersome, but takes no extra thought once you've done it a few times.

Also, to move a window from one monitor to the other, for best results you'll need to bring the window all the way to the far side of the destination monitor first, then position it where you'd like. Example, if a window at top right of my right monitor needs to be full right on my left monitor, I would press super+alt+numpad_4 several times until the window was all the way to the left, then super+alt+numpad_6 to bring it to full right on the left monitor.

If any of this is confusing, please let me know and I'd be happy to clarify. It is quite late (er... now early) so my brain grammaring no working good, and explaining things is becoming more difficult by the letter.

Please feel free to change any key combination you'd like to make things more suited to your needs.

Hopefully this helps, OP!


"Unix is simple. It just takes a genius to understand its simplicity."  - Dennis Ritchie (1941-2011), Unix Co-Creator
Unix philosophy

Offline

#3 2015-10-10 07:35:04

tranjeeshan
Member
Registered: 2015-10-02
Posts: 69

Re: [SOLVED] Window positioning with NUM Keypad in bunsenlabs (Openbox)

alaskan-hippie wrote:

I actually just tested my instructions using the default rc.xml, and figured out what's going. The double hyphens used in the line "cb-aerosnap --right/left" is not permitted. Having double hyphens in xml markdown comments is disallowed for compatibility with SGML.  I haven't seen a way around this at all other than removing the double hyphens. So you can do one of two things:

1 Change the code as follows:

<!-- 
    <command>cb-aerosnap --left</command>
    -->

Change to

<!--
    <command>cb-aerosnap - -left</command>
-->

OR

2 Just remove that whole section:

REMOVE THE FOLLOWING
   

<keybind key="W-Right">
      <action name="GrowToEdgeEast"/>
    </keybind>
    <keybind key="W-Left">
      <action name="GrowToEdgeWest"/>
    </keybind>
    <keybind key="W-Down">
      <action name="GrowToEdgeSouth"/>
    </keybind>
    <keybind key="W-Up">
      <action name="GrowToEdgeNorth"/>
    </keybind>
    <keybind key="W-A-Left">
      <action name="Execute">
        <command>cb-aerosnap - -left</command>
      </action>
    </keybind>
    <keybind key="W-A-Right">
      <action name="Execute">
        <command>cb-aerosnap - -right</command>
      </action>
    </keybind> 
	<keybind key="W-Right">
      <action name="GrowToEdgeEast"/>
    </keybind>
    <keybind key="W-Left">
      <action name="GrowToEdgeWest"/>
    </keybind>
    <keybind key="W-Down">
      <action name="GrowToEdgeSouth"/>
    </keybind>
    <keybind key="W-Up">
      <action name="GrowToEdgeNorth"/>
    </keybind>
    <keybind key="W-A-Left">
      <action name="Execute">
        <command>cb-aerosnap - -left</command>
      </action>
    </keybind>
    <keybind key="W-A-Right">
      <action name="Execute">
        <command>cb-aerosnap - -right</command>
      </action>
    </keybind> 

I just removed it entirely on my end.


"Unix is simple. It just takes a genius to understand its simplicity."  - Dennis Ritchie (1941-2011), Unix Co-Creator
Unix philosophy

Offline

#4 2015-10-10 07:35:54

tranjeeshan
Member
Registered: 2015-10-02
Posts: 69

Re: [SOLVED] Window positioning with NUM Keypad in bunsenlabs (Openbox)

tranjeeshan wrote:

Okay, I made a backup copy of rc.xml and then removed the part that weren't necesary. The problem's gone.
The problem was, XML or SGML doesn't allow double hyphen in comment. Thanks everyone


"Unix is simple. It just takes a genius to understand its simplicity."  - Dennis Ritchie (1941-2011), Unix Co-Creator
Unix philosophy

Offline

#5 2015-10-10 14:13:04

nobody0
Disabled account
Registered: 2015-09-29
Posts: 664

Re: [SOLVED] Window positioning with NUM Keypad in bunsenlabs (Openbox)

tranjeeshan wrote:
tranjeeshan wrote:

Okay, I made a backup copy of rc.xml and then removed the part that weren't necesary. The problem's gone.
The problem was, XML or SGML doesn't allow double hyphen in comment. Thanks everyone

Which part 'that wasn't necessary' did you remove?
Doing

 <command>cb-aerosnap - -left</command>

doesn't work, so could you explain what you've done to make it work?

Offline

#6 2015-10-10 14:42:04

damo
....moderator....
Registered: 2015-08-20
Posts: 4,827

Re: [SOLVED] Window positioning with NUM Keypad in bunsenlabs (Openbox)

I have this, and it works...

    <keybind key="A-Left">
      <action name="Execute">
        <command>damo-aerosnap.sh --left</command>
      </action>
    </keybind>
....
    <keybind key="W-t">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>Terminal</name>
        </startupnotify>
        <command>terminator --profile=desktop</command>
      </action>
    </keybind>
....
    <keybind key="W-minus">
      <action name="Execute">
        <command>transset-df -p --dec 0.1</command>
      </action>
    </keybind>

So double-hyphens are allowed it seems


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#7 2015-10-10 15:06:24

nobody0
Disabled account
Registered: 2015-09-29
Posts: 664

Re: [SOLVED] Window positioning with NUM Keypad in bunsenlabs (Openbox)

True.

<command>cb-aerosnap --left</command>

works, but

<command>cb-aerosnap - -left</command>

doesn't work. The white space between hyphen don't work. The cb-aerosnap, or bl-aerosnap works, only it won't return the window to the former place, just a bit below. Alskan-hippie's code is okay, but it is not aerosnap.

Btw, is your damo-aerosnao.sh different from cb- or bl-aerosnap? Could you give the code? Does it bring back the window to the former position?

Offline

#8 2015-10-10 17:20:05

damo
....moderator....
Registered: 2015-08-20
Posts: 4,827

Re: [SOLVED] Window positioning with NUM Keypad in bunsenlabs (Openbox)

ostrołęk wrote:

...

Btw, is your damo-aerosnao.sh different from cb- or bl-aerosnap? Could you give the code? Does it bring back the window to the former position?

Yes, and it can move straight to the opposite side, and deal with panels and dual monitors  angel

But it is a bash script WIP, and is quite slow to do the switches.

BTW the (python) cb-aerosnap is buggy, and bl-aerosnap has been held back in consequence. @Unia has been working on an improved version.


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#9 2019-03-22 17:47:20

Colonel Panic
Member
Registered: 2018-11-13
Posts: 24

Re: [SOLVED] Window positioning with NUM Keypad in bunsenlabs (Openbox)

Hi everyone. Just posting to say thank you to alaskan-hippie (is he still here?) for the keypad bindings above. They work just fine (and to prive it, I'm posting this from a window on the bottom left hand corner of my screen).

Cheers,

Colonel Panic .

Offline

Board footer

Powered by FluxBB