Bleeding on the Edge: Popup Window Whack-a-Mole


When you run development versions of software and most of your packages are marked ~amd64, you can get some really strange surprises. For instance, today one of my system tray notifications got stuck in the top left of my screen on top of all my other windows, as you can see in the picture below.

Stuck notification window
Stuck notification window

Now I knew for a certainty that window had to have some kind of handle or ID attached to it that I could grab and manipulate it with (I actually know this from my exclusively Windows programming days). One of the things I absolutely love about Linux is that fact that it gives you all the tools you need to troubleshoot and repair a running system in place (I want to get a shirt printed that says “Rebooting Is Not A Solution” to wear at work). Most of the time your troubles can be alleviated by killing or restarting a particular service, not the machine.

But in this case that service was a window, and I had no idea what program opened it. To my rescue came a neat little tool called xdotool.

Crystal user root on 10 in ~
$ emerge -a xdotool

 * IMPORTANT: 2 config files in '/etc/portage' need updating.
 * See the CONFIGURATION FILES and CONFIGURATION FILES UPDATE TOOLS
 * sections of the emerge man page to learn how to update config files.

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] x11-misc/xdotool-3.20150503.1-r1  USE="-examples" 

Would you like to merge these packages? [Yes/No]

As useful and easy as the Internet is these days, I still decided to comb the man pages to learn how to use this thing.

Crystal user root on 10 in ~
$ man xdotool
selectwindow
Get the window id (for a client) by clicking on it. Useful for having scripts query you humans for what window to act on. For example, killing a window by clicking on it: xdotool selectwindow windowkill

Well what do you know? That kind of looked useful, and fortunately the example was exactly what I was looking to accomplish. I ran xdotool selectwindow windowkill and my cursor turned into a strange sort of reticle. Then I clicked on the rogue window and poof, gone!


Leave a Reply