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.

Figure 3: The Devilspie2 documentation isn't great, but the README lists all available functions.

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.

Figure 4: Xdotool, a great alternative for automation, sends virtual clicks and key presses to apps.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Brightside and Devil’s Pie

    If the no-frills Metacity window manager doesn’t give you the functio nality you need, try the Metacity add-ons Brightside and Devil’s Pie.

  • Introduction

    This month in Linux Voice.

  • Pipelight: Using Silverlight on Linux

    Video-on-demand services often don't play well with Linux because they depend on Microsoft's Silverlight browser plugin. Luckily, you can call on the Wine offshoot Pipelight to rescue your next home movie night.

  • Flash Plugins in Linux

    PPAPI, NPAPI, Pepper Flash, Fresh Player – just a lot of gibberish? We check out the background of Flash in Linux and provide tips on how to rule out the worst bugs in the technology.

  • Conky System Monitor

    This light-weight system monitor keeps you informed about your computer's performance.

comments powered by Disqus
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.

Learn More

News