X11 has a common system for window notifications: the urgency hint. The relevant section of the ICCCM standard:
The UrgencyHint flag, if set in the flags field, indicates that the client deems the window contents to be urgent, requiring the timely response of the user. The window manager must make some effort to draw the user's attention to this window while this flag is set.
Some window managers are uncompliant and don't support this. Possibly as a result, people really like to reinvent this particular wheel: notify-send, growl, and more. My WM (notion) does support this very well, with some really nice UI integration. Thus applications can request to be drawn as urgent. This really begs for a commandline tool so shells can request the user's attention at key points. For instance I really want to say something like
make; seturgent
I.e. this would launch a source build, and when the build completes, this particular terminal emulator window would request the user's attention. The build could take a long, time, and the user may want to do stuff with the build products, but in the meantime they can go do something else.
This seturgent
tool didn't exist, so I wrote one:
#!/usr/bin/perl # Copyright 2012,2013 Dima Kogan # License: GPL 3 or later use strict; use warnings; use feature qw(say); use X11::Protocol; use X11::Protocol::WM; use X11::WindowHierarchy; # if no arguments are given, sets urgency on the current window # # if an argument is given, uses it as a regex on the window name (all matches # are set as urgent) my $usage = "$0 [regex on the window name]"; die $usage if @ARGV > 1; my $x = X11::Protocol->new() or die "Couldn't open display"; my @ids; if( ! @ARGV ) { @ids = ($ENV{WINDOWID}); } else { my @windows = x11_filter_hierarchy( filter => qr{$ARGV[0]} ) or die "No matching windows found"; say "Found " . scalar(@windows) . " matching windows"; @ids = map {$_->{id}} @windows; } foreach my $id(@ids) { die "No window id" unless $id; X11::Protocol::WM::change_wm_hints( $x, $id, urgency => 1 ); }
This uses X11::WindowHierarchy to find the window, and X11::Protocol::WM to set the urgency hint. Both are available in Debian. Usage is very straightforward: with no arguments, the current window is set urgent. Otherwise, the one and only argument is treated like a regex on the window title. If a single match is found, that window is set urgent.
Now I can say
make; seturgent