ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RP] Active screen?


From: Martin
Subject: [RP] Active screen?
Date: Sat, 1 Aug 2009 01:19:51 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

I've finally entered the 21:th century & have gotten myself a dual-head setup.
This has complicated my use of ratpoison to some degree, when I found that I
needed to know which monitor that is currently the active one, but found no
easy way to have ratpoison tell it to me.

This is the script I wrote.

Has anyone else wanted to find the currently active monitor? Did you solve it
more elegantly than this? Is there perhaps a way to have ratpoison tell it
right away?

Comments?

#!/usr/bin/perl
#
# This script exists to show which screen is currently active, since I could
# not find any way to extract that information from ratpoison by any simpler
# means.
#
# It finds the active screen by taking the output of the ratpoison commands
# fdump and sfdump and comparing them.
#
# fdump will provide something like this:
#(frame :number 1 :x 0 :y 0 :width 1200 :height 1920 :screenw 1200 :screenh 
1920 :window 190840842 :last-access 173 :dedicated 0),
#
# sfdump will provide something like this:
#(frame :number 0 :x 0 :y 0 :width 768 :height 1024 :screenw 768 :screenh 1024 
:window 16777217 :last-access 172 :dedicated 0) 0,
#(frame :number 1 :x 0 :y 0 :width 1200 :height 1920 :screenw 1200 :screenh 
1920 :window 190840842 :last-access 173 :dedicated 0) 1,
#
# By search for the existance of the fdump output inside the sfdump output, it
# is possible to know which physical screen is active.

use strict;
use warnings;

my $sfdump=`$ENV{'RATPOISON'} --command "sfdump"`;
my $fdump=`$ENV{'RATPOISON'} --command "fdump"`;

$/ = ",\n";
chomp ($fdump);

my @screens = split (/([(][^(]*,)([(][^(]*,)/, $sfdump);

foreach ( @screens ) {
        next unless m/^[(]/;
        my ( $screen ) = m/.* ([0-9]*)[,]/;
        print $screen;
        if (grep (/$fdump/, $_)) {
                print "*";
        } else {
                print "-";
        }
        print $_, "\n";
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]