Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2017-11-24 07:24 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (345 votes). Check out past polls.