Scripted Window Actions
Going Further
Now you've seen how Devilspie2 can – over time – make your workflow more efficient by automating all of the fiddly little window management tasks that you do every day by hand, but it includes many other routines, as well, such as making windows invisible from task lists or pagers, placing them always on top of other windows, or centering them in the screen (like a splash screen).
At the time of writing, Devilspie2's manual [3] was very much incomplete and didn't even include examples, but that's what this tutorial is for! You can, however, bring up a rather dry but detailed list of additional window management routines in the README [4] (Figure 3). Let me know how you get on with this handy little tool and how it makes a difference to your daily work! Also check out two other WM tools in the "Alternatives: wmctrl and xdotool" box that provide similar functionality for automating tasks, but with other features and benefits.
Alternatives: wmctrl and xdotool
As you've seen, thanks to Lua scripting, Devilspie2 is quite easy to work with. If you want a smaller tool for interacting directly with windows, though, then take a look at wmctrl
[5]. This is a "command-line tool to interact with an EWMH/NetWM compatible X Window Manager" – which means pretty much all major WMs written (or updated) in the last decade. Examples include Blackbox, IceWM, Englightenment, and Window Maker.
As with Devilspie2, you can use wmctrl to move windows around, resize them, put them on specific workspaces, and do other tasks. It's a more demanding tool to use, in that some familiarity with X Window System underpinnings is important, but the documentation is fairly good. You can even do some more advanced things like changing window titles on the fly and resizing the current desktop.
Another tool that's slightly related is xdotool
[6], which lets you "simulate keyboard input and mouse activity, move and resize windows, etc." (i.e., you can create scripts that send virtual key presses and mouse clicks to windows) (Figure 4). It's especially useful for automating certain tasks, such as clicking on a series of buttons in a complicated dialog, so you can even use it for automatic testing of GUI software. Like wmctrl
, it's not the easiest program to use out of the box and has a somewhat steep learning curve, but it's worth putting in some time to learn the basics. Still, wmctrl
and xdotool
are both included in the package repositories of all big-name distros, so you don't have to go far to find them.
Infos
- Devilspie2: http://www.nongnu.org/devilspie2/
- Lua: https://www.lua.org
- Devilspie2 manual: http://www.gusnan.se/devilspie2/manual.php
- Devilspie2 README: http://git.savannah.gnu.org/cgit/devilspie2.git/plain/README
- wmctrl: http://tripie.sweb.cz/utils/wmctrl/
- xdotool: http://www.semicomplete.com/projects/xdotool
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Red Hat Adds New Deployment Option for Enterprise Linux Platforms
Red Hat has re-imagined enterprise Linux for an AI future with Image Mode.
-
OSJH and LPI Release 2024 Open Source Pros Job Survey Results
See what open source professionals look for in a new role.
-
Proton 9.0-1 Released to Improve Gaming with Steam
The latest release of Proton 9 adds several improvements and fixes an issue that has been problematic for Linux users.
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.