You are not logged in.
I am trying to create some remaps for positioning the currently open window. What I want to achieve is something like this:
Demonstration #1
1. window is open and spans the whole screen
2. press W+Down and the window should span the lower half of the screen only
3. press W+Down again and the window should return to span the whole screen
(same idea for W+Up/Right/Left)
Demonstration #2
1. window is open and spans the whole screen
2. press W+Down and the window should span the lower half of the screen only
3. press W+Left after it and the window should span the lower left part of the screen only
4. press W+Right after that and the window should span the lower half of the screen
(same idea for the other remaps)
Demonstration #3
1. window is open and spans the whole screen
2. press W+Down and the window should span the lower half of the screen only
3. press W+Left after it and the window should span the lower left part of the screen only
4. press W+Left again after that and the window should span the left half of the screen
(same idea for the other remaps)
What I've reached to is the code attached below.
Now the problem is in Demonstration #3 because I don't know how to detect the position of the window when it is unmaximized both horizontally and vertically, i.e. whether it is in the bottom left or in the bottom right of the screen.
I think the position must be known because suppose that the window is in the bottom left, pressing W+left should maximize the window vertically. But if the window is in the bottom right, then pressing W+left should maximize the window horizontally.
So any idea how to check that?
If not possible, do you have any idea about a workaround to achieve what I described?
Thanks a lot in advance.
<keybind key="W-Up">
<action name="Raise"/>
<action name="If"><query target="default"><maximized>no</maximized><maximizedhorizontal>yes</maximizedhorizontal></query>
<then>
<action name="Maximize"/>
</then>
<else>
<action name="ToggleMaximize"><direction>vertical</direction></action>
<action name="MoveResizeTo"><y>0</y><width>50%</width><height>50%</height></action>
</else>
</action>
</keybind>
<keybind key="W-Down">
<action name="Raise"/>
<action name="If"><query target="default"><maximized>no</maximized><maximizedhorizontal>yes</maximizedhorizontal></query>
<then>
<action name="Maximize"/>
</then>
<else>
<action name="ToggleMaximize"><direction>vertical</direction></action>
<action name="MoveResizeTo"><y>-0</y><width>50%</width><height>50%</height></action>
</else>
</action>
</keybind>
<keybind key="W-Right">
<action name="Raise"/>
<action name="If"><query target="default"><maximized>no</maximized><maximizedvertical>yes</maximizedvertical></query>
<then>
<action name="Maximize"/>
</then>
<else>
<action name="ToggleMaximize"><direction>horizontal</direction></action>
<action name="MoveResizeTo"><x>-0</x><width>50%</width><height>50%</height></action>
</else>
</action>
</keybind>
<keybind key="W-Left">
<action name="Raise"/>
<action name="If"><query target="default"><maximized>no</maximized><maximizedvertical>yes</maximizedvertical></query>
<then>
<action name="Maximize"/>
</then>
<else>
<action name="ToggleMaximize"><direction>horizontal</direction></action>
<action name="MoveResizeTo"><x>0</x><width>50%</width><height>50%</height></action>
</else>
</action>
</keybind>Offline
If you can live with adjusting your goals just slightly, very similar outcomes could be achieved quite trivially with openbox's built-in actions "ShrinkToEdge" and "GrowToEdge". The changes would be primarily that to toggle out of the lower half of the screen you'd not be able to just press W-Down again, but you'd hit W-Up, and to switch from a window being in the lower half to being in the upper half, you'd hit W-Up twice. (edit ... oops, nope, it'd not be quite that simple - but still if you're flexible in your goals I'd strongly recommend using these built in actions: to switch from the lower half to upper half, you'd need two bindings, one for grow and another for shrink, e.g., W-S-Up then W-Up).
Alternatively, if you do want to implement this exactly as you outlined, you will need your own script to detect the window position for which there are a few tools - I suspect wmctrl would be the simplest.
(edit: I'd provide some links to the openbox docs, but unfortunately openbox.org went down just a couple weeks ago and it seems it may be permanently gone. The content is available on archive.org, but searching for info there is trickier.)
Last edited by Trilby (2024-07-09 12:55:28)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
If you can live with adjusting your goals just slightly, very similar outcomes could be achieved quite trivially with openbox's built-in actions "ShrinkToEdge" and "GrowToEdge". The changes would be primarily that to toggle out of the lower half of the screen you'd not be able to just press W-Down again, but you'd hit W-Up, and to switch from a window being in the lower half to being in the upper half,
you'd hit W-Up twice.(edit ... oops, nope, it'd not be quite that simple - but still if you're flexible in your goals I'd strongly recommend using these built in actions: to switch from the lower half to upper half, you'd need two bindings, one for grow and another for shrink, e.g., W-S-Up then W-Up).Alternatively, if you do want to implement this exactly as you outlined, you will need your own script to detect the window position for which there are a few tools - I suspect wmctrl would be the simplest.
(edit: I'd provide some links to the openbox docs, but unfortunately openbox.org went down just a couple weeks ago and it seems it may be permanently gone. The content is available on archive.org, but searching for info there is trickier.)
Thanks a lot, wmctrl in a script alongside with some other tools did the trick.
Have a great day!
Offline