Wallpaper Script
Rafael George
george.rafael at gmail.com
Thu Jan 27 23:30:50 EST 2005
Hi, guys here is an script that i wrote for setting the wallpapers on
Openbox, can somebody give me suggestions of it, thanks. Im beginnng
one for the themes too .
#!/usr/bin/perl -w
# Author: cored
# Date: 27/01/05
# License: GPL
use strict;
use Getopt::Long;
my $cmd = 'feh --bg-scale ';
my $help = '';
my $dir = '';
my $wal = '';
sub usage {
print "Usage: $0 [OPTION]
With this script you can set your wallpapers on OpenBox
Option:
-d --dir : Wallpapers directory
-h --help: This screen \n";
}
sub show_menu {
my $dir = shift;
opendir (DIR, "$dir") || die "Can't opendir $dir: $!";
my @all = readdir DIR;
closedir DIR;
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
print "<openbox_pipe_menu>\n\n";
foreach my $i ( @all ) {
if ( $i ne "." && $i ne ".." ) {
print "<menu id=\"$i\" label=\"$i\">\n";
opendir (DIR,"$dir/$i") || die "Can't opendir $dir.$i: $!";
my @walls = grep { /\.(gif|jpe?g|png)$/i } readdir DIR;
close DIR;
foreach my $w ( @walls ) {
my $p = $w;
$p=~s|\.\w+||g;
$p=~s/(^\w)/\U$1/;
print "<item label=\"$p\">\n";
print "<action name=\"Execute\">";
print "<execute>$cmd $dir/$i/$w</execute>";
print "</action>";
print "</item>\n";
}
print "</menu>\n";
}
}
print "</openbox_pipe_menu>";
}
GetOptions('help'=>\$help,'dir=s'=>\$dir);
if ( $help ) {
usage();
}
if ( $dir ) {
show_menu($dir);
}
--
Grimoire Guru
SourceMage GNU/Linux
More information about the openbox
mailing list