LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Recommended random wallpaper program using feh won't work (https://www.linuxquestions.org/questions/linux-software-2/recommended-random-wallpaper-program-using-feh-wont-work-879816/)

hilltownboy 05-10-2011 09:19 AM

Recommended random wallpaper program using feh won't work
 
The following program from wiki.Debian.org/openbox is shown under "Setting your background image with feh" (random wallpaper), but for me it comes up with error messages.

Code:

#wallpaper.sh
WALLPAPERS="~/wallpapers"
ALIST=( 'ls -wl ~/wallpapers' )
RANGE=${#ALIST[@]}
let "number=$RANDOM"
let LASTNUM="'cat $WALLPAPERS/.last' + number"
let "number=$LASTNUM % $RANGE"
echo $number > $WALLPAPERS/.last

feh --bg-scale $WALLPAPERS/${ALIST[$number]}

Here are the error messages, which seem to say that /.last is not valid.
Is that right? If so, how to fix?

Code:

feh --bg-scale $WALLPAPERS/${ALIST[$number]}
./wallpaper.sh: line 7: let: LASTNUM='cat ~/wallpapers/.last' + number: syntax error: operand expected (error token is "'cat ~/wallpapers/.last' + number")
./wallpaper.sh: line 8: let: number= % 1: syntax error: operand expected (error token is "% 1")
./wallpaper.sh: line 9: ~/wallpapers/.last: No such file or directory
feh WARNING: ~/wallpapers/ - File does not exist
feh ERROR: Couldn't load image in order to set bg


andrewthomas 05-10-2011 09:26 AM

Post the output of

Code:

ls -al ~/wallpapers
from the root of your home directory

arizonagroovejet 05-10-2011 02:01 PM

Well for starters specifying ~/wallpapers in both of these lines

Code:

WALLPAPERS="~/wallpapers"
ALIST=( 'ls -wl ~/wallpapers' )

is daft. The second line should use the WALLPAPERS variable.

The script as you post it won't work because you're using ' where you should be using `

Also the script is way more complicated than it needs to be. Try this.

Code:

!#/bin/bash
WALLPAPERS="${HOME}/wallpapers"
cd "${WALLPAPERS}"
feh --bg-scale "$(ls | sort -R | head -1)"

You could reduce that by a line by not using the WALLPAPERS variable.

mikeb380 05-11-2011 12:19 AM

random wallpaper
 
I don't have a clue on what you asked, but I have been using a gui program called "Desktop Nova" along with "Desktop Nova-Tray. You can set up to get Wallpaper from various files and can tell it to randomize it. Can also set up the period between each graphic. I am using photos in two groups and it works wonderfully. Hope this helps you
Michael :Pengy:

hilltownboy 05-11-2011 10:23 AM

The short program offered by Arizonagroovejet (reduced to two lines as suggested) works perfectly for me, so I'll stay with that. You caught me in a syntax error with the longer program from the wiki ( ' that should be ` ), but I still did not get it to work.
To reply to andrewthomas:

Code:

total 1016
drwxr-xr-x  2 root  root    4096 Apr 23 12:53 .
drwxr-xr-x 37 norman norman  4096 May 11 10:20 ..
-rw-r--r--  1 norman norman 434723 Apr 23 12:42 BlueGoosecoloradg.jpg
-rw-r--r--  1 norman norman 114604 Apr 23 12:45 blue goose pigeon island.JPG
-rw-r--r--  1 norman norman 113483 Apr 23 12:46 blue goose running.JPG
-rw-r--r--  1 norman norman  71036 Apr 23 12:49 dsc00345.jpg
-rw-r--r--  1 norman norman  34085 Apr 23 12:48 GeorgeTrey.jpg
-rw-r--r--  1 norman norman 111280 Apr 23 12:48 nsw V & aunt nancy.JPG
-rw-r--r--  1 norman norman 111412 Apr 23 12:53 pool1.JPG

Thanks for the help, everyone

ikisham 05-11-2011 01:31 PM

iDesk is great for that and very lightweight.

Unfortunately it seems its wiki is down (maybe forever?).
But a while ago I wrote some instructions to set it in antiX's faq in Brazilian Portuguese. Maybe you could translate it with google: http://sblinux.org/antix-port/#Como_...fundo_de_tela_
Below is a sample conf file for the rotating background form ~/Wallpaper every 1 minute:
Code:

  Background.File: image.jpg
  Background.Delay: 1
  Background.Source: ~/Wallpaper
  Background.Mode: Scaled
  Background.Color: #C2CCFF

To have a fixed image, leave 'Background.Source:' empty and put the image path in 'Background.File:'.
antiX, it seems, doesn't come anymore with idesk and its GUI config tool but I'll try and find out wich one it used.

ikisham 05-11-2011 01:40 PM

Here are some GUI tools for idesk:
http://crunchbanglinux.org/forums/to...desk-tool-gui/
http://fixxxer.mx/blog-en/?p=6
http://icecc.sourceforge.net/idesktools.html

antiX used to use tidesktool and it worked fine.
I desk page (if only for screenshots as the wiki is down): http://sourceforge.net/projects/idesk/

hilltownboy 09-30-2011 10:44 AM

To recap, i.e. How to program Random Wallpapers with feh:
With wallpaper images filed in a file called wallpapers in one's home directory, use the following two commands:

cd ~/wallpapers
feh --bg-scale "$(ls / sort -R / head -1)" &

I have these in my autostart file (~/.config/openbox/autostart.sh) followed by any other commands desired on startup


All times are GMT -5. The time now is 09:54 AM.