View previous topic :: View next topic |
Author |
Message |
Kenadin n00b

Joined: 17 May 2002 Posts: 48 Location: Lexington, Kentucky, USA
|
Posted: Thu Apr 15, 2004 6:43 pm Post subject: Change background script for Openbox |
|
|
Here is a very useful set of scripts to change your background from the Openbox menu. I use Esetroot to change backgrounds but this should basically work with other methods also.
First you need to create the file newbg.sh in your .config/openbox directory which includes this:
Code: |
#!/bin/bash
ln -sf $1 ~/.config/openbox/current.jpg
Esetroot -fit ~/.config/openbox/current.jpg
|
Next create the file images.sh in your .config/openbox directory which includes, (I found this script from another user here on the boards):
Code: |
#!/bin/bash
#
# Shows all files in "DIR" location, associating an action "CMD" to them.
# Be careful with file names, openbox doesn't work fine with strange characters
# in its menu. Use only english characters.
#
# In order to use it, you must add the following line to your menu.xml:
#
# <menu id="1234" label="My files" execute="/path/filemenu" />
#
# Configuration:
#
# file location with terminal slash
DIR=$1
# command to call
CMD=~/.config/openbox/newbg.sh
#
# Simple script:
echo "<openbox_pipe_menu>"
for name in $DIR*
do
echo "<item label=\"$(echo $name | gawk -F/ '{print $NF}' | tr 'A-Z' 'a-z')\">"
echo "<action name=\"Execute\"><execute>$CMD $name</execute></action>"
echo "</item>"
done
echo "</openbox_pipe_menu>"
|
Now the last file you need to edit is you .config/openbox/menu.xml file to contain:
Code: |
<menu id="1234" label="Wallpaper" execute="~/.config/openbox/images.sh /home/phoenix/pics/" />
|
You should replace /home/phoenix/pics/ with the location of your images. Finally chmod u+x on images.sh and newbg.sh. After you reload your openbox config you should have a new menu that list your images and if you click one it should change your background to that image.
Also if you want the last background you selected to stay for the next time you log in add
Code: |
Esetroot -fit ~/.config/openbox/current.jpg &
|
to you .xinitrc file or .xsession file to load when openbox loads.
Kenadin |
|
Back to top |
|
 |
clar77 Apprentice


Joined: 02 Feb 2004 Posts: 210 Location: Charm City, MD
|
Posted: Fri Apr 16, 2004 2:33 am Post subject: |
|
|
very nice! thanks. I changed the Esetroot command to -scale. works a little better with my twinview. again, very cool. _________________ Pointless screenshots
My dogs :) |
|
Back to top |
|
 |
monotux l33t


Joined: 09 Sep 2003 Posts: 751 Location: Stockholm, Sweden
|
Posted: Fri Apr 16, 2004 7:59 am Post subject: |
|
|
Place this thread in the "Documentation, Tips & Tricks"-section  _________________ Computer science is no more about computers than astronomy is about telescopes. |
|
Back to top |
|
 |
kezzla Apprentice


Joined: 21 Aug 2003 Posts: 253 Location: Austin, TX
|
Posted: Tue May 25, 2004 5:02 am Post subject: |
|
|
I can't get this working for the life of me ! Please help...I apologize in advance at my n00b ob3 knowledge..but so far it I am LOVING it !!! I'm using pypanel + torsmo...I almost crapped my pants with mousewheel = desktop switcher !!! Can't wait to get gdesklets going !
I can change my wallpaper manually via:
# Esetroot -fit /path/to/mywallpaper
I think I'm messing up on my ~/.config/openbox/menu.xml entry.
I'm confused where do I put it ? I've tried all over that damn file.
It seems that your entry is incomplete as there is no end tag or anything ?
Where **exactly** does this go ??? >>
Quote: |
<menu id="1234" label="Wallpaper" execute="~/.config/openbox/images.sh /path/to/mywallpaper/" /> |
Can you guys post your menu.xml ? I would totally LOVE this feature  |
|
Back to top |
|
 |
kezzla Apprentice


Joined: 21 Aug 2003 Posts: 253 Location: Austin, TX
|
Posted: Tue May 25, 2004 5:08 am Post subject: |
|
|
Ok I am a total freaking retard !!!
For you other n00bs I got it to work putting this entry in my "root-menu" stanza:
Quote: | <menu id="1234" label="Wallpaper" execute="~/.config/openbox/images.sh /home/phoenix/pics/" /> |
Thanks for the GREAT tip ! Works perfectly...  |
|
Back to top |
|
 |
monotux l33t


Joined: 09 Sep 2003 Posts: 751 Location: Stockholm, Sweden
|
Posted: Tue May 25, 2004 5:45 am Post subject: |
|
|
I can't make it work :'(
I did put the Code: | <menu id="1234" label="Wallpaper" execute="~/.config/openbox/images.sh /home/phoenix/pics/" /> | in my root-menu, and changed the path to the folder containing my wallpapers.
I have all...
fuck it. I had forgotten to do a
I works now ^^ _________________ Computer science is no more about computers than astronomy is about telescopes. |
|
Back to top |
|
 |
newbie_100 Guru


Joined: 17 Jan 2004 Posts: 335 Location: Ashdod, IsraHell
|
Posted: Wed Jul 07, 2004 3:37 pm Post subject: |
|
|
I've added the dynamic menu but the problem is that i cant see all the wallpapers because i have too many and the menu doesn't fit to the screen =\
is there a way to make a new submenu after every 30~40 wallpapers? |
|
Back to top |
|
 |
tgrey n00b

Joined: 30 Aug 2003 Posts: 14
|
Posted: Sat Aug 14, 2004 3:40 am Post subject: |
|
|
newbie_100 wrote: | is there a way to make a new submenu after every 30~40 wallpapers? |
i modified the script that is called to generate the menu, this splits it up into submenus by using a counter. you can define the max you want per group by changing where "MAX" is set. each group is numbered sequentially.
also notice i hard coded my image directory too, so it's not passed as an arg, change it back to $1 if you want the original behavior.
Code: |
#!/bin/bash
# file location with terminal slash
DIR="/home/tgrey/backgrounds/"
# command to call
CMD="Esetroot -fit"
# maximum number of images to show per sub group
MAX=20
echo "<openbox_pipe_menu>"
# initialize the file and menu count
MENU=1
COUNT=1
# start the first submenu
echo "<menu id=\"bg-$MENU\" label=\"$MENU\">"
for name in $DIR*
do
if [ $COUNT -gt $MAX ]; then
# count maxed, start new menu and reset counter
MENU=`expr $MENU + 1`
echo "</menu>"
echo "<menu id=\"bg-$MENU\" label=\"$MENU\">"
COUNT=1
fi
echo "<item label=\"$(echo $name | gawk -F/ '{print $NF}' | tr 'A-Z' 'a-z')\">"
echo "<action name=\"Execute\"><execute>$CMD $name</execute></action>"
echo "</item>"
COUNT=`expr $COUNT + 1`
done
# end the started menu
echo "</menu>"
echo "</openbox_pipe_menu>"
|
|
|
Back to top |
|
 |
rush_ad l33t


Joined: 22 Jul 2004 Posts: 863 Location: New Jersey, USA
|
Posted: Sat Aug 21, 2004 11:17 pm Post subject: |
|
|
anyone know if this also works with 'feh'? |
|
Back to top |
|
 |
tgrey n00b

Joined: 30 Aug 2003 Posts: 14
|
Posted: Sun Aug 22, 2004 12:06 am Post subject: |
|
|
rush_ad wrote: | anyone know if this also works with 'feh'? |
if you mean using feh to set the background, sure, i don't see why not. just replace the "Esetroot -fit" with whatever feh command you would type at a console. |
|
Back to top |
|
 |
codergeek42 Bodhisattva

Joined: 05 Apr 2004 Posts: 5142 Location: Anaheim, CA (USA)
|
Posted: Sun Aug 22, 2004 4:21 am Post subject: |
|
|
I figured I would do something similar, so here's how to integrate RSS feeds into your Openbox menu using PHP 5's new SimpleSML extension (WAY EASIER than the XML-handling of PHP 4, imho) (change $browser setting as needed). I would recommend saving this to your ~/scripts/openbox/menu-rss-feed.php (but you are free to name it something else or save it in a different location of course ^_^): Code: | #!/usr/bin/env php
<?php
# Notice: This requires PHP 5 (the CLI) with SimpleXML support !
#
# Copyright 2004 Peter Gordon <admin@ramshacklestudios.com>
# This comes with NO WARRANTY WHATSOEVER. You are free to use this as you please under
# the terms of the GNU General Public License, version 2.
# This requires that register_argv_argc is set to 'yes' or '1' in your php.ini file.
$browser = '/usr/bin/firefox';
$xml = simplexml_load_string(implode('',file($_SERVER['argv'][1])));
echo '<openbox_pipe_menu>';
foreach($xml->item as $article) {
echo "<item label=\"{$article->title}\">";
echo ("<action name=\"Execute\"><execute>{$browser} {$article->link}</execute></action>");
echo "</item>";
}
echo '</openbox_pipe_menu>';
?>
| Don't forget to make it executable: Code: | chmod a+x ~/scripts/openbox/menu-rss-feed.php | Then insert it into your menu.xml like so: Code: | <menu id="openbox-Technocrat-menu" label="Technocrat" execute="~/scripts/openbox/menu-rss-feed.php http://technocrat.net/rss" />
<menu id="openbox-SlashDot-menu" label="Technocrat.net" execute="~/scripts/openbox/menu-rss-feed.php http://slashdot.org/rss" /> | This should work with all RSS-compliant XML feeds, such as other news sites, for example.
(P.S. I think it would be more practical as a Perl script, since I don't think people would want to emerge PHP 5 just to use this, but I figure most people have Perl installed. Can a Perl guru write this in Perl please? Thnx!)
edit: maybe a Bash guru can do it with wget/awk/etc. ? _________________ ~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF |
|
Back to top |
|
 |
codergeek42 Bodhisattva

Joined: 05 Apr 2004 Posts: 5142 Location: Anaheim, CA (USA)
|
Posted: Sun Aug 22, 2004 8:30 am Post subject: |
|
|
SHWEET. Works like a charm now. Thanx. _________________ ~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF |
|
Back to top |
|
 |
rush_ad l33t


Joined: 22 Jul 2004 Posts: 863 Location: New Jersey, USA
|
Posted: Sun Aug 22, 2004 3:12 pm Post subject: |
|
|
works great. thanks a lot. |
|
Back to top |
|
 |
nightm4re Guru


Joined: 20 Jun 2004 Posts: 519 Location: Providence, RI, USA
|
Posted: Tue Aug 24, 2004 9:13 pm Post subject: |
|
|
hey, i did something sorta similar, although not quite as cool as the menu thing. Since I use a multihead display, i have seperate backgrounds for each, so i made a couple scripts.
First, a bgset script, which for me executes feh's set capability. Here's setbg.sh:
Code: |
#!/bin/bash
feh --bg-scale $1
|
Then, I have a startob3 script in order to do the display thing.
Code: |
#!/bin/sh
export DISPLAY=:0.1
setbg.sh ~/.config/openbox/bgs/background-$DISPLAY
openbox &
export DISPLAY=:0.0
setbg.sh ~/.config/openbox/bgs/background-$DISPLAY
exec openbox
|
As you can tell, the beauty is in making symbolic links to the background images, which are named with a display string in them, so they are named background-:0.0 and background-:0.1. You can adapt this to any number of heads, obviously.
I havne't yet come up with a good method of making the symbolic links yet, i was hoping to figure out how to make a little chooser dialog similar to picking gnome's background, but no dice so far. _________________ Nitrogen - GtkMM based background setter/restorer, please test!
Minuslab | d.minuslab.net |
|
Back to top |
|
 |
dayul Apprentice


Joined: 02 Jun 2004 Posts: 180 Location: Blackpool, England
|
Posted: Fri Dec 10, 2004 10:47 am Post subject: |
|
|
just thought i would add that you can use xsetbg which comes with xloadimage instead of Esetroot if you dont use Eterm etc. |
|
Back to top |
|
 |
monotux l33t


Joined: 09 Sep 2003 Posts: 751 Location: Stockholm, Sweden
|
Posted: Fri Dec 31, 2004 1:46 pm Post subject: |
|
|
codergeek42 wrote: | I figured I would do something similar, so here's how to integrate RSS feeds into your Openbox menu using PHP 5's new SimpleSML extension (WAY EASIER than the XML-handling of PHP 4, imho) (change $browser setting as needed). I would recommend saving this to your ~/scripts/openbox/menu-rss-feed.php (but you are free to name it something else or save it in a different location of course ^_^): Code: | #!/usr/bin/env php
<?php
# Notice: This requires PHP 5 (the CLI) with SimpleXML support !
#
# Copyright 2004 Peter Gordon <admin@ramshacklestudios.com>
# This comes with NO WARRANTY WHATSOEVER. You are free to use this as you please under
# the terms of the GNU General Public License, version 2.
# This requires that register_argv_argc is set to 'yes' or '1' in your php.ini file.
$browser = '/usr/bin/firefox';
$xml = simplexml_load_string(implode('',file($_SERVER['argv'][1])));
echo '<openbox_pipe_menu>';
foreach($xml->item as $article) {
echo "<item label=\"{$article->title}\">";
echo ("<action name=\"Execute\"><execute>{$browser} {$article->link}</execute></action>");
echo "</item>";
}
echo '</openbox_pipe_menu>';
?>
| Don't forget to make it executable: Code: | chmod a+x ~/scripts/openbox/menu-rss-feed.php | Then insert it into your menu.xml like so: Code: | <menu id="openbox-Technocrat-menu" label="Technocrat" execute="~/scripts/openbox/menu-rss-feed.php http://technocrat.net/rss" />
<menu id="openbox-SlashDot-menu" label="Technocrat.net" execute="~/scripts/openbox/menu-rss-feed.php http://slashdot.org/rss" /> | This should work with all RSS-compliant XML feeds, such as other news sites, for example.
(P.S. I think it would be more practical as a Perl script, since I don't think people would want to emerge PHP 5 just to use this, but I figure most people have Perl installed. Can a Perl guru write this in Perl please? Thnx!)
edit: maybe a Bash guru can do it with wget/awk/etc. ? |
I can't make it work
Code: | [oscar@pirate openbox]$ php menu-rss-feed.php
Warning: implode(): Bad arguments. in /home/oscar/.config/openbox/menu-rss-feed.php on line 12
<openbox_pipe_menu>
Warning: Invalid argument supplied for foreach() in /home/oscar/.config/openbox/menu-rss-feed.php on line 14 |
_________________ Computer science is no more about computers than astronomy is about telescopes. |
|
Back to top |
|
 |
|