XFCE and moving windows around with the keyboard
During a recent apt-get update && apt-get dist-upgrade I suddenly found myself with the horrors that are Gnome 3 and the Gnome shell, and of course, at the least opportune moment when I was actually planning on heading into an office (more about that later). I've always been a big Sawfish fan, and was annoyed when Gnome replaced that with Metacity, but I always managed to get Sawfish back up again. No more luck now, and without a Debian package maintainer I decided to try out XFCE.
I found XFCE to be as easy to use with the keyboard as Sawfish but with one big missing issue: I couldn't change the size and position of windows at the keyboard anymore. I hardly use a mouse as it hurts too much, and always relied on those keyboard shortcuts to position my windows so I was quite a bit at a loss. After some searching I ran into a post on nabble that contained a script that almost did what I want. It uses a bunch of standard X tools (xprop and xwininfo) to find some information about the active window and its properties. Then depending on some parameters it would use wmctrl to move and/or resize the window. For example: ./bin/window-geometry-control.sh -m left would move the window 1 pixel to the left.
That's all good, but way too slow. I basically just want to bump my windows to the top, right, bottom and left sides of my screen. So besides the simple move and resize, I added what Sawfish originally also had: move left/right/top and bottom; and well as resize-to left/right/top and bottom. Now with the command ./bin/window-geometry-control -b left I can move the active window all the way to the left, and with ./bin/window-geometry-control -s bottom I can resize my window from its current position all the way to the bottom of the screen. To each of the four directions and two methods I assigned keyboard shortcuts in xfce4-settings-manager, Keyboard, Application Shortcuts.
The screenshot above shows those assigned keyboard shortcuts. I've put the modified script on github. As you can see I hardcoded the width and height of my own screen in it. Feel free to make this dynamic and send a pull request.
Comments
I am quite happy with Fedora's XFCE spin on my desktop (inside a virtual machine). For now I can live with GNOME 3 on my laptop but as soon as I will have some spare time I will replace it there with XFCE as well, I think.
I switched to XFCE recently as well, and will definitely try out these scripts. I have a widescreen monitor as my second monitor so I'll need to figure out a way of doing "middle" as well since I usually have two windows side-by-side on there, but fullscreen on my laptop screen.
Thanks for sharing, this will be a huge help to me :)
@LornaJane: I think I'll be extending on it a little bit soon, as there are still a few things that I can't do (such as: go back to original size). Expect an update!
Thanks for the pointers. I greatly simplified my own implementation to do the bare minimum, and it's quite snappy. I made 5 separate scripts. You'll need to tweak the "magic constants" of 1920x1200, 24, and 2 to reflect your own resolution, vertical window manager chrome, and horizontal chrome, respectively.
move-up:
#!/bin/sh wmctrl -r :ACTIVE: -e 0,-1,0,-1,-1
move-left:
#!/bin/sh wmctrl -r :ACTIVE: -e 0,0,-1,-1,-1
move-down:
#!/bin/bash winid=`xprop -root _NET_ACTIVE_WINDOW | sed 's/^.*# \(0x[^,]*\),.*$/\1/'` height=$((24 + `xwininfo -stats -id $winid | sed -n 's/^ Height: \([0-9]\+\)$/\1/p'`)) wmctrl -r :ACTIVE: -e 0,-1,$((1200 - $height)),-1,-1
move-right:
#!/bin/bash winid=`xprop -root _NET_ACTIVE_WINDOW | sed 's/^.*# \(0x[^,]*\),.*$/\1/'` width=$((2 + `xwininfo -stats -id $winid | sed -n 's/^ Width: \([0-9]\+\)$/\1/p'`)) wmctrl -r :ACTIVE: -e 0,$((1920 - $width)),-1,-1,-1
move-middle:
#!/bin/bash winid=`xprop -root _NET_ACTIVE_WINDOW | sed 's/^.*# \(0x[^,]*\),.*$/\1/'` width=$((2 + `xwininfo -stats -id $winid | sed -n 's/^ Width: \([0-9]\+\)$/\1/p'`)) height=$((24 + `xwininfo -stats -id $winid | sed -n 's/^ Height: \([0-9]\+\)$/\1/p'`)) wmctrl -r :ACTIVE: -e 0,$((960 - $width / 2)),$((600 - $height / 2)),-1,-1
Hope that helps you out!
Thanks so much for the information Derick and Brandon. I finally can manage my windows from keyboard in a comfortable way.
Life Line
I've finished reading Children of Memory, the third book in the series.
Another interesting take on forms of intelligent life.
A fourth one is going to get released later this year.
Updated a post_box, a beauty shop, and a restaurant; Confirmed 2 clothes shops, 2 pet shops, and a restaurant
I walked 5.9km in 1h40m39s
Updated a bicycle_parking
Updated 2 waste_baskets
I walked 7.9km in 1h37m12s
Created 3 waste_baskets; Updated 3 bus_stops, 2 benches, and 2 waste_baskets
I walked 8.1km in 1h25m53s
I walked 1.2km in 9m31s
I walked 9.4km in 1h39m05s
Merge branch 'xdebug_3_5'
Merged pull request #1071
Fixed issue #2411: Native Path Mapping is not applied to the initial …
Created 2 waste_baskets; Updated 3 waste_baskets, 2 benches, and 2 other objects; Deleted a waste_basket
I walked 7.9km in 1h45m36s
RE: https://phpc.social/@phpc_tv/116274041642323081
Now that phpc.tv and phpc.social are part of the same umbrella, I've upped my yearly contributions to their Open Collective: https://opencollective.com/phpcommunity/projects/phpc-social
Merge branch 'xdebug_3_5'
Merged pull request #1070
I walked 7.2km in 1h10m26s
Fixed issue #2405: Handle minimum path in .xdebug directory discovery
I've published a new blog post: "Human Creations", on the difference in content generation by LLMs, and the creation of text, art and code by humans.
You can find it at https://derickrethans.nl/human-creations.html or at @blog
I walked 7.8km in 1h38m32s
RE: https://phpc.social/@afilina/116274024588235234
It's good to see that more and more people are realising that the Web can be for-good, without all the enshittification.
That's why I'm happy to see endeavours like phpc.tv springing up, and helping out where I can.
Taking back the control of how the Web is for people, by people, without big tech making it all shit.
Created a waste_basket; Updated 5 crossings and a bicycle_parking
I walked 10.7km in 2h35m10s


Shortlink
This article has a short URL available: https://drck.me/xfcekeyb-8ug