View previous topic :: View next topic |
Author |
Message |
Adrien Advocate
Joined: 13 Jul 2004 Posts: 2308 Location: Bretagne
|
Posted: Sat Apr 16, 2005 10:15 am Post subject: [openbox] setting wallpaper from menu |
|
|
Hello!
I'm running openbox and just have a simplequestion.
What I'd basically like to do is:
1- Create a folder in which I'd stock all my wallpapers, for example: ~/backgrounds (not too difficult actually)
2- Create an entry in the .config/openbox/menu.xml which would display the ~/backgrounds contents and allow me to change the background from theopenbox menu.
I noticed some people on the forum have written scripts to do the job, but I was simply wondering if a script is absolutely needed for this, as I don't know much about xml abilities and syntax.
Can anyone help? |
|
Back to top |
|
|
enrique Guru
Joined: 03 Sep 2002 Posts: 342 Location: Denmark
|
Posted: Sat Apr 16, 2005 11:01 am Post subject: |
|
|
You could either generate the menu staticly (by hand), or use a script. The most simple way/less work involved is to use a scipt.
I use this very simple perl one:
Code: | #!/usr/bin/perl -w
use warnings "all";
use strict;
my $paper_changer = "qiv -x -e -n"; # This is the command to change the paper. Season to fit.
if (scalar(@ARGV) == 1) { # Specifying a directory
print("<openbox_pipe_menu>\n");
&listpic($ARGV[0]); # Call the subroutines with the dir as arg
print("</openbox_pipe_menu>\n");
}
sub listpic {
my $dir = $_[0];
opendir(DIR, "$dir") || die "Can't opendir $dir: $!";
my @papers = readdir(DIR); # Put all files/dirs into the @papers array
closedir DIR;
foreach my $file (@papers) {
if(-d "$dir/$file" && !("." =~ /$file/ || ".." =~ /$file/)) { # Run recursively through all sub directories
print("<menu id=\"$file\" label=\"$file\">\n");
&listpic("$dir/$file");
print("</menu>\n");
} elsif (!-d "$dir/$file") {
my @image = grep { (! /^\./) && ( /^.*\.[pPjJgG][nNpPiI][gGfF]/ )} $file;
print("
<item label=\"@image\">
<action name=\"Execute\">
<execute>$paper_changer $dir/@image</execute>
</action>
<action name=\"Execute\">
<execute>ln -fs $dir/@image $ENV{HOME}/.config/openbox/current</execute>
</action>
</item>");
}
}
} |
_________________ Kind regards, enrique
Workstation,HTPC,Powerbook |
|
Back to top |
|
|
bet1m l33t
Joined: 04 Dec 2004 Posts: 631 Location: Kosova/Prishtine
|
Posted: Sat Apr 16, 2005 11:24 am Post subject: |
|
|
Esetroot works fine _________________ #370559 |
|
Back to top |
|
|
Adrien Advocate
Joined: 13 Jul 2004 Posts: 2308 Location: Bretagne
|
Posted: Sat Apr 16, 2005 1:41 pm Post subject: |
|
|
enrique wrote: | You could either generate the menu staticly (by hand), or use a script. The most simple way/less work involved is to use a scipt. |
Ok thanks for the script, the thing is: How do I run a perl script?
And, is this script going to generate a whole menu or just a wallpaper entry in the menu? |
|
Back to top |
|
|
mil0t n00b
Joined: 24 Jun 2003 Posts: 62
|
Posted: Sat Apr 16, 2005 1:45 pm Post subject: |
|
|
So i used before bsetroot on fluxbox, but now i use GNOME so try bsetroot .
//mil0t _________________ emerge --pretend love | genlop --pretend |
|
Back to top |
|
|
enrique Guru
Joined: 03 Sep 2002 Posts: 342 Location: Denmark
|
Posted: Sat Apr 16, 2005 2:17 pm Post subject: |
|
|
Adrien wrote: | Ok thanks for the script, the thing is: How do I run a perl script?
And, is this script going to generate a whole menu or just a wallpaper entry in the menu? |
Add the following to you: ~/.config/openbox/menu.xml :
Code: | <menu id="Backgrounds-menu" label="Backgrounds" execute="ob-bg.pl /path/to/your/backgrounds" /> |
The ob-bg.pl is the perl script, it needs to be in you path somewhere _________________ Kind regards, enrique
Workstation,HTPC,Powerbook |
|
Back to top |
|
|
|