Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

automate your linux window manager

by zentara (Archbishop)
on Jun 05, 2005 at 16:45 UTC ( #463733=snippet: print w/replies, xml ) Need Help??
Description: I've always dreaded the X startup I have to go thru, where I switch thru 10 virtual desktops and start applications in each one. I know there is "desktop suspend-to-disk", but that requires a kernel patch, etc. This is just a simple Perl script, that will cycle thru your virtual desktops and start applications. You may need to adjust the delay, if your computer is slow, to prevent a slow-starting app from appearing on the adjacent desktop. Tested with ICEWM, and works with EWMH compliant window managers, and requires the wmctrl program.

I have 10 desktops, so adjust your script according to your desktop setup.

use warnings;
use strict;
use X11::WMCtrl;

# based on the EWMH specification: 
# wmctrl only works with window managers which implement 
# this specification. 
# The homepage of wmctrl: 
# wmctrl must be installed somewhere in the path 

my $wmctrl = X11::WMCtrl->new;

my %setup= (
     0 => '/home/zentara/mozilla/',
     1 => '/usr/bin/sylpheed',
     2 => '/usr/bin/tk-spamchecker',
     3 => undef,
     4 => undef,
     5 => 'xterm -fn 10x20 -ls -geometry 97x35+0+25 -e /usr/bin/mc',
     6 => undef,
     7 => 'xterm -fn 10x20 -ls -geometry 97x35+0+25 -e /usr/bin/mc',
     8 => '/usr/bin/agent',
     9 => '/usr/bin/girc'

foreach my $wrksp (0..9){
      my $cmd = $setup{$wrksp};
      if(defined $cmd){ system("$cmd &"); sleep 3 }

#my $app = $windows[0]->{title}; 

Replies are listed 'Best First'.
Re: automate your linux window manager
by converter (Priest) on Jun 06, 2005 at 01:05 UTC

    This module includes a minor error that you should watch out for: &X11::WMCtrl::wmctrl uses $_ with the <> operator in a while loop without localizing it. I've submitted a bug and a patch.

    $ perl -MX11::WMCtrl -e '$c=X11::WMCtrl->new; $c->switch($_), sleep 1 +for 0..6,1' Modification of a read-only value attempted at /usr/lib/perl5/site_per +l/5.8.5/X11/ line 380.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://463733]
[Corion]: hippo: Yes, but I'm not sure that it's even worth the effort of implementing it at all...
[Corion]: You'll only ever need that option if you have a long-running query whose results are not cached by your DB already, and in those cases I presume that the programmer will want to maintain the temporary tables themselves - I wouldn't know when to drop ...
[Corion]: ... the temporary tables, and also don't have a good idea on how to create unique table names for them
[hippo]: OIC. In that case leave it out but invite feature requests and see if any of the users suggest it. :-)
[Corion]: Talking about this makes me realize that it's likely only a half useful idea. But it still would be convenient to have as an option...
[Corion]: hippo: Hmmm - yeah, I could document it and wait for code implementing that option to show up ;-D

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2017-02-23 15:36 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (347 votes). Check out past polls.