2011/04/24

Move to Different X-screens with a Perl Script

I tried writing this in a bash script but for some reason I failed miserably so I wrote it in some I knew.   I have my XFCE WM where it focuses where the mouse is so if you don't have it set up like that, it may not completely work right, I dunno. 

#!/usr/bin/perl
use strict;
use warnings;

my $display = $ENV{'DISPLAY'};
#print "my dispaly is $display\n";
if (!(defined $display)){
        exit 1;
}
elsif ($display eq ":0.1") {
        system("xdotool mousemove --screen 0 640 512");
        #print("Switching to xscreen 0\n");
}
else {
        system("xdotool mousemove --screen 1 920 600");
        #print("Switching to xscreen 1\n");
}

exit 0;
 This can easily be changed to suit your own needs.  You could have one called move right, left etc if you have more than two x-screens.  The "640 512" and "920 600" are the x y cords of the middle of my screen.  See the man page for xdotool for more info.

It's a real quick and dirty script so.  If you make any improvements to it, please let me know!

No comments:

Post a Comment