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.

#!/usr/bin/perl use warnings; use strict; use X11::WMCtrl; # based on the EWMH specification: # http://www.freedesktop.org/standards/wm-spec/ # wmctrl only works with window managers which implement # this specification. # The homepage of wmctrl: # http://sweb.cz/tripie/utils/wmctrl/ # wmctrl must be installed somewhere in the path my $wmctrl = X11::WMCtrl->new; my %setup= ( 0 => '/home/zentara/mozilla/run-mozilla.sh', 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){ $wmctrl->switch($wrksp); my $cmd = $setup{$wrksp}; if(defined $cmd){ system("$cmd &"); sleep 3 } $wmctrl->maximize($wrksp); } #my $app = $windows[0]->{title}; #$wmctrl->maximize($app); #$wmctrl->unmaximize($app); #$wmctrl->shade($app); #$wmctrl->unshade($app); #$wmctrl->close($app);

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/WMCtrl.pm line 380.