Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Perl: the Markov chain saw
 
PerlMonks  

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.

#!/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); 


Comment on automate your linux window manager
Download Code
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.

Back to Snippets Section

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://463733]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-04-20 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls