Openbox windows snapping by dragging window to corners?

Is possible windows 10 snapping on Openbox? Openbox error See last POST

It seems it is: https://wiki.archlinux.org/index.php/openbox#Window_snapping

Shortcut: Super (Win) + Left / Right -- moves window to the left / right

Add the following code to ~/.config/openbox/rc.xml

<keybind key="W-Left">
    <action name="UnmaximizeFull"/>
    <action name="MaximizeVert"/>
    <action name="MoveResizeTo">
        <width>50%</width>
    </action>
    <action name="MoveToEdge"><direction>west</direction></action>
</keybind>
<keybind key="W-Right">
    <action name="UnmaximizeFull"/>
    <action name="MaximizeVert"/>
    <action name="MoveResizeTo">
        <width>50%</width>
    </action>
    <action name="MoveToEdge"><direction>east</direction></action>
</keybind>

To reload openbox configuration files without restarting it, use openbox --reconfigure. I think the command affects the currently focused window.

Edit: updated with code and explanation
PS: I haven't tried it myself, but ArchWiki usually works for me.

1 Like

whats tha capital W

yeah i google that also. but that code only lets you snap left and right?:S

Yes. How would you like your windows to snap? I might come up with something.

atm im replacing "MaximizeVert" to "Maximize Hor" to make the up and down snaping but it doesnt seems to work

Try

<keybind key="W-Down">
   <action name="Unmaximize"/>
</keybind>
<keybind key="W-Up">
   <action name="Maximize"/>
</keybind>

Or, hmm, maybe I know what you want. Do you want the windows to snap to the lower and upper half of the screen?

<keybind key="W-Up">
<action name="UnmaximizeFull"/>
<action name="MaximizeHor"/>
<action name="MoveResizeTo">
<height>50%</height>
</action>
<action name="MoveToEdge"><direction>north</direction></action>
</keybind>

With that code it snaps on the top of the screen but it does not maximize horizontaly

This should do it. Hopefully.

<keybind key="W-Up">
    <action name="UnmaximizeFull"/>
    <action name="MoveResizeTo">
        <height>50%</height>
    </action>
    <action name="MoveToEdge"><direction>north</direction></action>
</keybind>

<keybind key="W-Up">
<action name="UnmaximizeFull"/>
<action name="MaximizeHor"/>
<action name="MoveResizeTo">
<height>50%</height>
<width>100%</width>
</action>
<action name="MoveToEdge"><direction>north</direction></action>
</keybind>

That works!!

Oh, well. A bit of miscommunication in there (I thought you don't want it to maximize horizontally). But I'm glad I could help and you got what you want.

dont worry. but can you put North-east as a direction on the code?

I think so, but you'll have to try. This should move it to the upper-right quarter of the screen:

<keybind key="W-E">
    <action name="UnmaximizeFull"/>
    <action name="MoveResizeTo">
        <height>50%</height>
        <width>50%</width>
    </action>
    <action name="MoveToEdge"><direction>north</direction><direction>east</direction></action>
</keybind>

it doesnt, maybe you cannot set direction>northeast like that. was that from wiki?

Sadly Wiki doesn't show multiple edges, so I'm guessing

(Edit: This turns out to cause a syntax error)

<keybind key="W-E">
    <action name="UnmaximizeFull"/>
    <action name="MoveResizeTo">
        <height>50%</height>
        <width>50%</width>
    </action>
    <action name="MoveToEdge"><direction>north</direction></action>
    <action name="MoveToEdge"><direction>east</direction></action>
</keybind>

And this could do the same just by releasing the window being dragged in the top-right corner:

<mouse>
  <context name="TRCorner">
    <mousebind button="Left" action="Release">
        <action name="UnmaximizeFull"/>
        <action name="MoveResizeTo">
            <height>50%</height>
            <width>50%</width>
        </action>
        <action name="MoveToEdge"><direction>north</direction></action>
        <action name="MoveToEdge"><direction>east</direction></action>
    </mousebind>
  </context>
</mouse>

You could try quicktile : https://github.com/ssokolow/quicktile

After the last code i see this

i cannot open any menu on openbox nor terminal

I'm not sure if it's the mouse binding causing that or the multiple directions of movement.

Its the multi direction, how can i access that file again?

Right, you're locked out. You can use a terminal login. User Ctrl+Alt+FX, one of them should be your X server and at least one of the other ones should be a terminal. Type you credentials and then use nano or vim to edit the file using nano ~/.config/openbox/rc.xml then you should be able to reload the openbox config from the same terminal using openbox --reconfigures

1 Like