Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi
I came to know about 'crontab' command which allows you to schedule task at regular interval.
Then I found out 'gconftool-2' command to change desktop wallpaper in GNOME.
let us say I have my desired 100 wallpapers numbered 1.jpg to 100.jpg.
Now I want that script should increment location at every execution by cron daemon.
That is
script's main command will be
Well, first you need to design the way you want to go about.
My proposal:
Quote:
Since you will want to add and/or delete background files you do not like, best would be to on each run create a list of currently existing files (ls *.jpg.... > existing.txt) and to keep list of already used files, where you would add a currently used file to that list (used.txt).
After creation of existing.txt, script compares it to used.txt to remove files from existing.txt that are also in used.txt, to avoid duplication. If all files have been used, empty the used.txt and set resulting list with all files from existing.txt.
Once you have prepared list of available files, either use the first one or use random number generator to select next file.
If gconftool-2 exits without errors, append that file to used.txt and exit.
I do not have time to create actual script, but implementation should not be to hard.
There is an option to create config file that will used several folders holding background files, desired way to select next file and maybe few other options.
I also did create a bash script to change background every certain period. But the problem with it is that everytime the background changes, the CPU usage will increase sometimes 100% for a short while. So if the background changed while playing a game such as alien-arena, there's a slight performance down.
CentOS and Fedora do not have packages for anything similar. Truth to be told, Gnome is designed for small memory and CPU requirements. I used default wallpaper for CentOS for 3 years since my desktop is covered with applications 90% of the time.
My plan is that I will keep all my wallpapers in ~/wp numbered from 1 to 100.
After every 5 minutes script will run.
My aim is to represent file by %d.jpg so that it can be incremented at every run & variable type should be static.
After file variable becomes 100 we will rename it to 1 using 'if'.
to catkin
I appreciate your detailed response.i will tag your post as 'software to change wall paper periodically' so that those who prefer software can find it easily.
But I like to use command & am also learning bash scripting.
Last edited by sumeet inani; 12-21-2009 at 04:57 AM.
Huwm, I think I should be generous to share my script since I create it thanks to this thread
So here you go:
Code:
#!/bin/bash
#Default values
pictdir="$HOME/Pictures"
time=1h
#Wallpaper names
fnme=('wp1.jpg' 'wp2.jpg' 'wp3.jpg')
fin=${#fnme[@]}
let bck=$fin-1
#Exit if the script is already running, just in case
#Got this part of script somewhere in this forum
if pidof -x $(basename $0) > /dev/null; then
for p in $(pidof -x $(basename $0)); do
if [ $p -ne $$ ]; then
echo "Script $0 is already running: exiting"
exit
fi
done
fi
#This is where the desktop wallpaper changes
for (( i=0;i<$fin;i++ )); do
sleep $time #wait for $time second(s)
gconftool-2 --type string --set /desktop/gnome/background/picture_filename $pictdir/${fnme[${i}]}
if [ $i -eq $bck ]; then
let i=-1
fi
done
There's more thing can be done with this script, but for now, it's as simple as this. If you're playing a game, better kill this script so that it would not interrupt your game.
to isolatedsh33p
In your case the script is running in background all the time ( when wallpaper is not being changed then it is sleeping ) while what I propose is that crontab will execute script to change wallpaper at regular intervals while in between two intervals script is not present in memory .
I think
i think that if variable's value is stored in file then its value will be static.
i mean
Suppose ~/int.txt initially contains 0
In our script
variable i takes its value from file int.txt & sets the wallpaper to ~/wp/0.jpg
Now increment i.
(i+1) >~/int.txt --note we are not appending value of i but overwriting int.txt file with next value.
In beginnning of script there will be condition
if(i>=99)
i=0;
so we can have 99 wallpapers.
What do you say ?
I don't know much scripting so please help ?
Last edited by sumeet inani; 12-21-2009 at 09:35 AM.
there was a early tinycore iso made by Master Okajima..
the background color changes at every boot, a function of his initrd or kernel?
I never took it apart but I thought it was neat that the background color would change at every boot on a read-only fs
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.