Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[openbox] setting wallpaper from menu
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
Adrien
Advocate
Advocate


Joined: 13 Jul 2004
Posts: 2308
Location: Bretagne

PostPosted: Sat Apr 16, 2005 10:15 am    Post subject: [openbox] setting wallpaper from menu Reply with quote

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
View user's profile Send private message
enrique
Guru
Guru


Joined: 03 Sep 2002
Posts: 342
Location: Denmark

PostPosted: Sat Apr 16, 2005 11:01 am    Post subject: Reply with quote

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
View user's profile Send private message
bet1m
l33t
l33t


Joined: 04 Dec 2004
Posts: 631
Location: Kosova/Prishtine

PostPosted: Sat Apr 16, 2005 11:24 am    Post subject: Reply with quote

Esetroot works fine :)
_________________
#370559
Back to top
View user's profile Send private message
Adrien
Advocate
Advocate


Joined: 13 Jul 2004
Posts: 2308
Location: Bretagne

PostPosted: Sat Apr 16, 2005 1:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
mil0t
n00b
n00b


Joined: 24 Jun 2003
Posts: 62

PostPosted: Sat Apr 16, 2005 1:45 pm    Post subject: Reply with quote

So i used before bsetroot on fluxbox, but now i use GNOME so try bsetroot :D.

//mil0t
_________________
emerge --pretend love | genlop --pretend
Back to top
View user's profile Send private message
enrique
Guru
Guru


Joined: 03 Sep 2002
Posts: 342
Location: Denmark

PostPosted: Sat Apr 16, 2005 2:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum