scripting compiz; could use some perl regexp help
pauljohn32 at gmail.com
Sat Jun 7 23:59:55 UTC 2008
Changing to Ubuntu has had side effects. A version of compiz that
works with no fussing!
Did you know that compiz is on the dbus, so you can tell it what to do
Awesome. With 1000s of backgrounds, I want the wallpaper to change on
all the sides of the cube all the time. What fun!
You can set images into the backgrounds array of the cube like so,
where I drop in A.jpg and B.jpg. You can put in as many as you want.
dbus-send --print-reply --type=method_call
Here's where I need your perl regexp help. I'm writing something to
query the background array and then change some of them. But I'm
mentally blocked on how to select the part between the quotation marks
here and convert to Perl array.
You can ask compiz to tell you the images it currently has and it
returns a bunch of text:
$ dbus-send --print-reply --type=method_call
method return sender=:1.15 -> dest=:1.28 reply_serial=2
In the Perl script, I run that method, and want to convert it to an
array that just has the quoted parts in the elements.
So far I have a bunch of really klunky code, stupid. Why can't I see
a way to just grab the bits between" " into a vector?
Here's the example:
my $getBG = "dbus-send --print-reply --type=method_call
my $existingBG = `$getBG`;
$existingBG =~ m/\".*\"/g;
$existingBG =~ s/string/,/g;
$existingBG =~ s/array//g;
$existingBG =~ s/\[//g;
$existingBG =~ s/\]//g;
$existingBG =~ s/.*,//;
$existingBG =~ s/.*$//;
@grepOut = grep(/".*"/, split(/,/, $existingBG));
print "Existing: $existingBG \n";
print "grepOut: @grepOut \n";
Here's the output I see when I run that:
$ ./pjcubebackground.pl -d /usr/local/share/Backgrounds/Italy/
,Existing: method return sender=:1.15 -> dest=:1.37 reply_serial=2
grepOut method return sender=:1.15 -> dest=:1.37 reply_serial=2
The first element in the grepOut array has that erroneous stuff before
the image name. Other than that, it is OK.
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas
More information about the ubuntu-users