Skip to content

Instantly share code, notes, and snippets.

@hcoyote
Created February 13, 2012 21:36
Show Gist options
  • Save hcoyote/1820684 to your computer and use it in GitHub Desktop.
Save hcoyote/1820684 to your computer and use it in GitHub Desktop.
Allow spawning of a new xterm on any work space that isn't setup as an Email work space.
#!/usr/bin/perl
use strict;
use warnings;
our $current_desk;
our @desks;
my $wmctrl = "/usr/bin/wmctrl";
open(WM, "$wmctrl -d|") or fail("Could not invoke $wmctrl -d: $!");
for my $line (<WM>) {
my ($portal, $current, undef, $geometry,
undef, $viewport, undef, $workarea, $workareasize, $label) = split(/\s+/, $line);
$desks[$portal] = {
geometry => $geometry,
viewport => $viewport,
workarea => $workarea,
label => $label,
};
$current_desk = $portal if $current eq '*';
}
if ($desks[$current_desk]{label} eq 'Email') {
print "[" . scalar localtime() . "] ";
print "Sorry, no new $0, we're on email page.\n";
exit;
} else {
system("xterm +ut -title '$ENV{HOSTNAME} - xterm' &");
}
sub fail {
my $message = shift;
exec "/usr/X11R6/bin/xmessage", $message;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment