wmutils tricks and tips - Desktop Customization & Workflow

Users browsing this thread: 1 Guest(s)
z3bra
Grey Hair Nixers
I read the docs of your WM, and it's pretty interesting ! You managed to get a lot done in a short period of time !

Be careful when relying on wmutils though. It looks like your WM is meant to be controlled over EWMH hints, which is the exact opposite of wmutils' goal.

As an example, in your sxhkdrc, you shouldn't rely on `pfw` to act on the active window. "Active" has a special meaning in the EWMH spec, because there is a corresponding attribute associated with it: "_NET_ACTIVE_WINDOW".

The active window isn't necessarily the one that has focus. So as far as you're using wmctrl to perform an action, you should specify ":ACTIVE:" as the window name, rather than relying on `pfw` (and that's one less fork !). This would be more solid, and would fit your WM's philosophy better (fully EWMH controlled).

I took the other path with glazier: having the WM do nothing, besides what wmutils can. I realised that having a tool in wmutils listenning for events ("wew"), is counter-efficient, and doesn't match what wmutils wants to be: A fully stateless set of utilities that directly send its requests to the X server.

Now about your questions ! As I said, wmutils is fully stateless, and doesn't have anything running in the background to track window positions, or whatever.

• changing tiling layout

Back when I was doing tiling, I had a script (tile.sh) that took as an argument the tiling mode (horiz, vert, full, stuff like that). When you run it, it recalculates EVERY window position, and place them according to the window stacking position (the order listed by lsw). the last one (with keyboard focused) was in the "Main area".

• and whether the script auto-tiles windows when changing workspace/group or opening/closing a window.

The only way you have to do it is with "wew", from wmutils-opt. At first I was triggering the tile.sh script on every CREATE/DELETE event. On such event, it would recalculate the whole layout, and windows were changing places according to their new position in the stack.

You can certainly imagine how inefficient and frustrating that can be.

I quickly moved back to calling the tile script manually from keybind or dmenu, ala cwm. This might sound tedious, however, I accommodated to it, and after some time, I liked that every window popped in "floating mode". This way temporary windows don't fuck up your tiling pattern.

• whether window state can switch between floating and tiling, and whether to keep track of its status and position

All windows poped floating. Running the script made every window tiled. Nothing in between (though now that there is "atomx", you can save states on a window. You probably won't though!)

My tile.sh script was written in shell, which means that it sucks to do proper window size calculations (no floating points, etc…). It was also slow to tile every window, so I would only call that script when appropriate, to avoid the flickering effect of the tiling recalculation.

When resizing a window, the other window wouldn't move to fill the remaining space. I tried to script it at some point, and quickly gave up. I cloud resize the master area however, by calling the script with a different percentage size for the master area (you had to make sure that the currently focused window was the main one, otherwise another window would take its place).

This means that tiling worked like in "dvtm". The only control you have is resizing the master window.

• tiling in different workspaces/groups

Please no. Everything was already too much of a pain.


As you probably guessed, I gave up on tiling with wmutils. It is simply not the best tool for the task (I gave up on tiling overall, but that's another topic). Tiling require many calculations per seconds, and for a smoother effect, you gotta send all your resize/move events to the X server BEFORE flushing the connections (so all changes appear at the same time).

wmutils tools, because they work in a standalone maner, need to flush the connection after every call, so every single change is visible, causing the flickering effect.

• monitor boundaries

wmutils has no visibility over what a monitor is, so I wrote randr to do that. It's pretty stupid, but get the job done. By default it prints the geometry of the monitor when the cursor is. Pass it a window id, and it gives the monitor where the window is (top-left corner).

When I switched to a 2 monitor setup, I replaced all occurrence of "wattr whxy $(lsw -r)" with "randr $(pfw) | cut -f 2-5". Simple as that. See my "maximize" script for example (note saving state in the ORIGINAL_SIZE atom 😉):

Code:
#!/bin/sh

# Make the current window cover the whole monitor, or change it back to
# its previous size if it's already maxed out

cur=$(pfw)
wid=${1:-$cur}
gap=1
atom="ORIGINAL_SIZE"

[ -z "$wid" ] && exit 1

# current window size
w="$(wattr w $wid)"
h="$(wattr w $wid)"
b="$(wattr b $wid)"

# monitor size / position
mx="$(randr $wid | cut -f 4 | head -n 1)"
my="$(randr $wid | cut -f 5 | head -n 1)"
mw="$(randr $wid | cut -f 2 | head -n 1)"
mh="$(randr $wid | cut -f 3 | head -n 1)"

# take gap/border size into account
mx=$((mx + gap))
my=$((my + gap))
mw=$((mw - 2 * (b + gap)))
mh=$((mh - 2 * (b + gap)))

# retrieve original size saved in the "$atom" X atom (if any)
size="$(atomx $atom $wid)"

if  [ -n "$size" ]; then
        wtp $size $wid
        atomx -d $atom $wid
else
        atomx ${atom}="$(wattr xywh $wid)" $wid > /dev/null
        wtp $mx $my $mw $mh $wid
fi

wtf $wid


Messages In This Thread
wmutils tricks and tips - by z3bra - 29-08-2015, 05:53 AM
RE: wmutils tricks and tips - by Wildefyr - 29-08-2015, 09:33 AM
RE: wmutils tricks and tips - by dkeg - 29-08-2015, 06:28 PM
RE: wmutils tricks and tips - by z3bra - 31-08-2015, 05:14 AM
RE: wmutils tricks and tips - by dkeg - 31-08-2015, 10:38 AM
RE: wmutils tricks and tips - by Wildefyr - 14-09-2015, 01:55 AM
RE: wmutils tricks and tips - by pranomostro - 14-09-2015, 08:11 AM
RE: wmutils tricks and tips - by dkeg - 14-09-2015, 08:19 AM
RE: wmutils tricks and tips - by pranomostro - 15-09-2015, 08:01 AM
RE: wmutils tricks and tips - by sagittarius - 15-06-2016, 03:58 PM
RE: wmutils tricks and tips - by pranomostro - 15-06-2016, 06:20 PM
RE: wmutils tricks and tips - by xero - 15-06-2016, 06:56 PM
RE: wmutils tricks and tips - by sagittarius - 15-06-2016, 07:06 PM
RE: wmutils tricks and tips - by lemons - 21-07-2016, 01:55 PM
RE: wmutils tricks and tips - by NetherOrb - 25-11-2016, 02:51 PM
RE: wmutils tricks and tips - by z3bra - 25-11-2016, 03:29 PM
RE: wmutils tricks and tips - by pfr - 24-08-2020, 09:43 PM
RE: wmutils tricks and tips - by seninha - 24-08-2020, 10:29 PM
RE: wmutils tricks and tips - by z3bra - 25-08-2020, 09:14 AM
RE: wmutils tricks and tips - by seninha - 25-08-2020, 01:53 PM
RE: wmutils tricks and tips - by z3bra - 26-08-2020, 03:25 AM
RE: wmutils tricks and tips - by pfr - 06-09-2020, 11:34 PM
RE: wmutils tricks and tips - by z3bra - 07-09-2020, 04:49 AM
RE: wmutils tricks and tips - by humky - 13-12-2021, 07:55 PM
RE: wmutils tricks and tips - by z3bra - 14-12-2021, 01:59 PM
RE: wmutils tricks and tips - by pfr - 08-02-2022, 10:04 PM
RE: wmutils tricks and tips - by z3bra - 09-02-2022, 07:22 AM
RE: wmutils tricks and tips - by pfr - 13-06-2023, 09:31 PM