Keyboard shorcuts for tiling windows or moving between monitors

Hi all,

I recently switched to Ubuntu LTS 22.04 and while I like it a lot, I am missing some shortcuts for tiling windows or moving them between monitors. In windows they used to be:

super + alt+ left / right: move window to left / right monitor.
super + left / right: set window to 50% width on left / right side of monitor.
super + up: maximize window.

Is there a way to add these to lubuntu? I tried playing around the shortcut keys app (global actions manager), but have no idea which command / dbus message to add there.

Any ideas?

Thanks and best regards

3 Likes

Here are a few - pointers.

The command you’re looking for is wmctrl.

You may have to go through a lot of trial and error to get what you want. If you succeed, it would be nice to see the fruits of your success here.

1 Like

Thank you for the hints, the wmctrl command looks quite powerful. I came up with some bash scripts, that perform the desired operations and can by called by shortcuts. Currently the screen coordinates are set as constants. Someone could come up with a way to read them programmatically if desired.

base.sh

#!/bin/bash

LEFT_SCREEN_WIDTH=1280
LEFT_SCREEN_HEIGHT=720
RIGHT_SCREEN_WIDTH=1920
RIGHT_SCREEN_HEIGHT=1080
X_LOCATION=$(xwininfo -id $(xdpyinfo | grep focus | grep -E -o 0x[0-9a-f]+) | awk -F ':' '/Absolute upper-left X/{print $2}')

maximize.sh

#!/bin/bash

wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz

minimize.sh

#!/bin/bash

wmctrl -r :ACTIVE: -b add,hidden

sendtoleftmonitor.sh

#!/bin/bash

wmctrl -r :ACTIVE: -e 0,0,0,-1,-1

sendtorightmonitor.sh

#!/bin/bash

. $(dirname $0)/base.sh
wmctrl -r :ACTIVE: -e 0,$LEFT_SCREEN_WIDTH,0,-1,-1

tileleft.sh

#!/bin/bash

. $(dirname $0)/base.sh

if (( $X_LOCATION < $LEFT_SCREEN_WIDTH )); then
    # Left Screen
    wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$(($LEFT_SCREEN_WIDTH/2)),-1
else
    # Right Screen
    wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$LEFT_SCREEN_WIDTH,0,$(($RIGHT_SCREEN_WIDTH/2)),-1
fi

tileright.sh

#!/bin/bash

. $(dirname $0)/base.sh

if (( $X_LOCATION < $LEFT_SCREEN_WIDTH )); then
    # Left Screen
    wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$(($LEFT_SCREEN_WIDTH/2-2)),0,$(($LEFT_SCREEN_WIDTH/2)),-1
else
    # Right Screen
    wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$(($LEFT_SCREEN_WIDTH+$RIGHT_SCREEN_WIDTH/2)),0,$(($RIGHT_SCREEN_WIDTH/2)),-1
fi
2 Likes

Hi,
You also could try this:

Greetings

If you are using the openbox method, the openbox file is at a different location after 20.04.

If you are upgrading from Lubuntu 20.04 LTS that has LXQt, this new version uses a different Openbox settings configuration file. If you have customized ~/.config/openbox/lxqt-rc.xml you will want to copy that file to ~/.config/openbox/rc.xml.

(link)

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.