Hobbes, not sure here but I guess you need to change #!/bin/sh for #!/bin/bash in the first script.
Anyone can tell us if it's right?
Rui Pais: nice signature. It's always nice to see that somebody else appreciates the same writers that I do.
Hobbes, not sure here but I guess you need to change #!/bin/sh for #!/bin/bash in the first script.
Anyone can tell us if it's right?
Rui Pais: nice signature. It's always nice to see that somebody else appreciates the same writers that I do.
Mariano
Ubuntu Linux User Group Argentina
Let's all get up and dance to a song/ That was a hit before your mother was born/ Though she was born a long long time ago
it should works both ways since the code it's simple and didn't require nothing specific to one shell. I had a some problems with certain scripts on edgy due to shell change but this one don't seems to have anything problematic to edgy/dash (didn't try it)
About Becket. Well a few moth ago i was in middle of reading Watt, when an opportunity appeared to saw 'waiting for Godot'.
My first time i saw it . And i was amazed by the quality of text, the solutions he gets for the self raised problems, the circular absorbing essence of the wait replacing the means of the action, the motives and even the lives of the personages!...
And then suddenly they said that 2 phrases... i was devastated with concept. More then depressing it's terrifying. Not the point of lose rights or some one take them away, but one volunteer "get rid of them".... (And worst, what was written with a burlesque, sad/comic, almost clowning intention it 's so common around us on our days, in our society... )
*NEW* OzOS (32 and 64bits e17-svn based distro) | e17 from code (SVN) made easy | Cafelinux Forum Welcomes All!___________________________________
ESTRAGON: We've lost our rights?
I got the same error, as well as it choked on a directoy with a space in the name. Upon further investigation, I have come up with an even simpler script, which at least works on my system:
You can follow davidY's instructions for executing, etc.Code:#!/bin/bash # Set your folder with the pics picsfolder="/media/documents/Desktops/" # Go to your folder with the pics cd "$picsfolder" # Get the name of a random file randomfile=`ls *.jpg *.png |sed -n $((RANDOM%$(ls *.jpg *.png |wc -l)+1))p` # start of gconftool command and set the desktop gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$picsfolder$randomfile"
I also don't know if this is a quirk of my system or not, but I find I have to add all the files to the list of available backgrounds (via the Desktop Background tool) before any of the files will actually display when set.
EDIT: you should also be able to extend this to multiple directories (provided they are sub-directories of the main directory) as follows:
To deal with multiple independent directories is more complicated; I'd suggest putting them all into a file and using cat to display the line (instead of the "ls" commands) and process it similarly.Code:#!/bin/bash # Set your folder with the pics picsfolder="/media/documents/Desktops/" # Go to your folder with the pics cd "$picsfolder" # Get the name of a random directory randomdir=`ls -d */ |sed -n $((RANDOM%$(ls -d */ |wc -l)+1))p` # Go to the selected directory cd "$randomdir" # Get the name of a random file randomfile=`ls *.jpg *.png |sed -n $((RANDOM%$(ls *.jpg *.png |wc -l)+1))p` # start of gconftool command and set the desktop gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$picsfolder$randomdir$randomfile"
EDIT 2: See post #22 for an improved version of the multiple directories approach.
Last edited by tweedledee; March 4th, 2007 at 03:47 AM. Reason: clarification
feel free to modify this to use random. it allows for multiple directories through a file and allows for spaces in directories and file names.
this also makes it possible to have different wallpaper directories per user since the .directorylist file is in the users home directory
Code:#!/bin/bash IFS=$'\n' ALIST=( `cat ~/.wallpaper/.directorylist` ) COUNTER=${#ALIST[@]} find "${ALIST[$COUNTER-1]}" -maxdepth 1 -mindepth 1 -type f | grep ".jpg\|.png" > .wallpaperlist let COUNTER-=1 until [ $COUNTER -lt 1 ]; do find "${ALIST[$COUNTER-1]}" -maxdepth 1 -mindepth 1 -type f | grep ".jpg\|.png" >> .wallpaperlist let COUNTER-=1 done ALIST=( `cat .wallpaperlist` ) RANGE=${#ALIST[@]} let LASTNUM="`cat .lastwallpaper` + 1" let "number = $LASTNUM % $RANGE" echo $number > .lastwallpaper echo "${ALIST[number]}" > .currentwallpaper gconftool-2 -t string -s /desktop/gnome/background/picture_filename "${ALIST[$number]}"
Last edited by eternalsword; January 27th, 2007 at 09:39 AM.
I tried to set this up and put the script in my home-folder. (Also written without sudo or sdgk) The pictures are also in a subfolder of home.
Now when I execute the script, my background turnes white. Any idea why that is? (I just want to understand... )
I've tried all the variants posted here, and without exception I had to add the background pictures to my list of desktop wallpapers before the images would appear (right-click on your desktop -> change wallpaper -> add wallpaper -> select all the files you want to rotate through (you can do them all at once if they are in the same folder). This basically just seems to make Nautilus "aware" of the files.
I'm having the same problem as other people in this thread. No matter what I do, I get no changes in my wallpaper. I have added all my wallpapers to the wallpaper manager.
This is my code:
#!/bin/bash
# Set your folder with the pics
picsfolder="/home/matthew/wallpapers"
# Go to your folder with the pics
cd "$picsfolder"
# Get the name of a random file
randomfile=`ls *.jpg *.png |sed -n $((RANDOM%$(ls *.jpg *.png |wc -l)+1))p`
# start of gconftool command and set the desktop
gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$picsfolder$randomfile"
Thanks for your help guys.
Btw, if i don't run it under gksu, the screen goes white
If i run it under gksu, there's no change in wallpaper.
what is the character in front of ls and after p is it ` the character which share the key with ~ ?
Because when I use this and try to run the script I get this error :
Code:scripts/changeWallpaper.sh: 10: arith: syntax error: "RANDOM%921+1"
When I change it to an apostrophe i.e. '
When I look in the gconftool for picture_filename it says
/media/d/Collection/Wallpapers/zNew/ls *.jpg *.png |sed -n $((RANDOM%$(ls *.jpg *.png |wc -l)+1))p
I am assuming its just quoting it.
Can someone please tell me what the problem is?
Last edited by pt123; March 3rd, 2007 at 10:01 PM.
Never mind guys, it worked =S The Cron script works... it changes automatically, but when I run the changewallpaper script manually, it doesn't change anything 0.o
Last edited by talcite; March 3rd, 2007 at 10:48 PM.
I changed it to ` now the script works in cron
but it doesn't work when it manually i.e. sh scripts/changeWallpaper.sh
I get the error:
scripts/changeWallpaper.sh: 10: arith: syntax error: "RANDOM%921+1"
What is causing this error?
Bookmarks