Ich habe mein Wallpaper-Script noch ein bisschen ausgebaut. Nun wird das ausgewählte Bild in ~/.pekwm/start eingetragen, damit es bei jedem Start von pekwm automatisch geladen wird.
#!/usr/bin/perl
#
# 2003 by x-way - http://waterwave.ch/weblog
#
# Add this to your menu, if you have pekwm's dynamic menu support:
#
# SubMenu = "Backgrounds" {
# Entry { Actions = "Dynamic /path/to/this/file /path/to/your/wallpapers" }
# }
#
use warnings "all";
use strict;
if($ARGV[0] eq '-set') {
my $wallpaper = $ARGV[1];
open(PKCONF, "<$ENV{HOME}/.pekwm/start") or die "Can't open ~/.pekwm/start";
my @file = <PKCONF>;
close(PKCONF);
my @file2 = ();
my $set = '';
foreach (@file) {
s/^xsetbg -center ".*"/xsetbg -center "$wallpaper"/gi;
push(@file2, $_);
if(index($_, 'xsetbg -center') == 0) {
$set = $_;
}
};
if($set eq "") {
push(@file2, "xsetbg -center \"".$wallpaper."\"");
}
open(PKCONF, ">$ENV{HOME}/.pekwm/start") or die "Can't write ~/.pekwm/start";
print(PKCONF @file2);
close(PKCONF);
} else {
print("Dynamic {\n");
for(my $i = 0; $i < scalar(@ARGV); $i++) {
my $dir = $ARGV[$i];
opendir(DIR, "$dir") || die "Can't opendir $dir: $!";
my @backgrounds = grep { (! /^\./) } readdir(DIR);
closedir DIR;
foreach my $x (@backgrounds) {
my $y = $x;
$y =~ s+.*/++g;
if(! -d "$dir/$x") {
$y =~ s/\.[^\.]*$//g;
$y =~ s/(_|-)[0-9]{3,4}(x[0-9]{3,4}|)//g;
$y =~ s/_/ /g;
$y =~ s/%20/ /g;
print("Entry = \"$y\" { Actions = \"Exec xsetbg -center \\\"$dir/$x\\\" && $0 -set \\\"$dir/$x\\\" \" }\n");
} else {
print("Submenu = \"$y\" {\nEntry { Actions = \"Dynamic $0 \\\"$dir/$x\\\" \" }\n}");
}
}
}
print("}\n");
}