SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2013-07-07 00:50:51

schwim
#! Die Hard
From: Interweb's #1 Devotee
Registered: 2012-10-11
Posts: 1,031
Website

Rotating random backgrounds(timed & on command)

Heya folks!

I thought I would share this before I forgot any of the steps.  It's hardly a feat of a superuser, but I find it awfully handy to have it written down somewhere and I thought it might be of use to others.  As is always the case, I'm not the genius behind this.  This is just a bunch of stuff I've grabbed via various Google searches.

WHAT IT IS: A random JPEG image is selected from a predefined directory and placed as the desktop background.  This happens on a 15 minute rotation and also has a keybind for those times I need or want another image displayed, for instance, if a light background is messing up something I want to see in Tint2 or terminal.

The first thing you need to do is have some background images saved.  I've got a few hundred saved to a Dropbox directory, since I wanted this feature across three computers and space and bw is cheap for me.  If you want some nifty, high quality backgrounds to get started with, give Wallpapers Wide a gander.

Okeedoke, here we go:

Step 1:

Open terminal.

cd ~
mkdir .scripts
geany

Insert into a new file:

#!/bin/bash
# directory containing images
DIR="/path/to/your/images"
# select a random jpg from the directory
PIC=$(ls $DIR/*.jpg | shuf -n1)
# use nitrogen to set wallpaper
nitrogen --set-zoom-fill $PIC

Be sure to change path to where your images are.

Save file as /home/<username>/.scripts/wallpaper_changer

Change <username> to match your username.

Close Geany and back in your terminal

cd .scripts
chmod +x wallpaper_changer

Step 2:
This step handles the timed changing of the image.

Still in terminal:

crontab -e

In the resulting editor, add the following line at the bottom.

*/15 * * * * DISPLAY=:0.0 /home/schwim/.scripts/wallpaper_changer

NOTE: Change "15" to whatever you'd like for interval between image changes.

CTRL+x and choose to save the file.

Step 3:
This will set a desktop image on startup of X.

Still in terminal:

geany ~/.config/openbox/autostart

In that file, find the following line(providing you haven't changed it):

nitrogen --restore && \

Change to:

DISPLAY=:0.0 /home/schwim/.scripts/wallpaper_changer && \

Save file and close.

Step 4:
This step will allow you to change image via hotkey.

Still in Geany:

Open ~/.config/openbox/rc.xml

Around line 330 of an unmodified file, you will find the start of the application keybinds.  This is where you would paste your addition:

<keybind key="A-w">
      <action name="Execute">
        <command>/home/<username>/.scripts/wallpaper_changer</command>
      </action>
    </keybind>

   
You must change <username> for your username.  You can also change the keybind to whatever you'd like.  I used "ALT+w".

Save file and close.

Reboot and you should be all set.  Hope this brightens someone's day!

Last edited by schwim (2013-07-07 00:56:13)

Offline

Help fund CrunchBang, donate to the project!

#2 2013-07-07 13:45:28

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 459

Re: Rotating random backgrounds(timed & on command)

sometimes a wallpaper looks better when it's scaled, tiled etc. something similar like the feature 'automatic' that u use in nitrogen.

is this possible that u include this?

Offline

#3 2013-07-07 14:00:40

schwim
#! Die Hard
From: Interweb's #1 Devotee
Registered: 2012-10-11
Posts: 1,031
Website

Re: Rotating random backgrounds(timed & on command)

Hi there Lion,

Are you asking if it's possible to change the switches per image or if it's just possible to have the bg's show as tiled instead of scaled(as it is for me)?

If it's per image, I don't know how that would be possible per random image.  If it's just overall, I'm sure the switches can be passed with no issue.

Offline

#4 2013-07-07 14:25:48

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 459

Re: Rotating random backgrounds(timed & on command)

a change per image would be useful.

but it would be also useful if i could use a combination: different wallpaper -> different conky-config = together

it's always a pain to position the conky-config when u use a different wallpaper.

Offline

#5 2013-07-07 14:27:13

schwim
#! Die Hard
From: Interweb's #1 Devotee
Registered: 2012-10-11
Posts: 1,031
Website

Re: Rotating random backgrounds(timed & on command)

A per-image configuration is well beyond the scope of this how-to.  This is just a pool of images that the script draws from.

Offline

#6 2013-07-07 14:46:57

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 459

Re: Rotating random backgrounds(timed & on command)

thanks for this information.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo