LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Reply
 
Search this Thread
Old 12-17-2009, 11:29 PM   #1
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Rep: Reputation: 47
a script to change wallpaper


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

gconftool-2 -t str -g /desktop/gnome/background/picture_filename <file>

Is it possible ?
wouldn't that be great that wallpaper changes after every 5 minutes ?
 
Old 12-17-2009, 11:42 PM   #2
~sHyLoCk~
Senior Member
 
Registered: Jul 2008
Location: /dev/null
Posts: 1,173
Blog Entries: 12

Rep: Reputation: 129Reputation: 129
Yup it's possible. Even I wrote a friend of mine a script to automatically download and set wallpaper everyday using curl and put it in cron.daily.

Regards
 
Old 12-18-2009, 01:46 AM   #3
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Original Poster
Rep: Reputation: 47
Can you tell how ?
I did not find it on http://pdg86.wordpress.com/
 
Old 12-20-2009, 05:08 AM   #4
DrLove73
Senior Member
 
Registered: Sep 2009
Location: Srbobran, Serbia
Distribution: CentOS 5.5 i386 & x86_64
Posts: 1,118
Blog Entries: 1

Rep: Reputation: 129Reputation: 129
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.
 
Old 12-20-2009, 11:32 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,544
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Wallpaper Tray? Here are notes of installing version 0.4.6 on ubuntu 8.04
Code:
1.apt-get install wallpaper-tray 
2.ln -s /usr/share/gnome/apps/Applications/wp_tray.desktop /usr/share/applications/  
3.Configured ~./wallpapers as wallpaper directory
4.Set change to 120 mins.
5.Gnome Control Centre, Personal, Sessions, Add
 	Name:  Start Wallpaper Tray
 	Command:  /usr/bin/wallpaper-tray
 	Comment:  Starts Wallpaper Tray
Alternatively create “~/.config/autostart/wallpaper-tray.desktop” with following content (first line is empty)

[Desktop Entry] 
Type=Application 
Encoding=UTF-8 
Version=1.0 
Name=No Name 
Name[en_IN]=Start wallpaper-tray 
Comment[en_IN]=Starts wallpaper-tray 
Comment=Starts wallpaper-tray 
Exec=/usr/bin/wallpaper-tray 
X-GNOME-Autostart-enabled=true

Last edited by catkin; 12-20-2009 at 12:36 PM. Reason: Removed spurious "Software changes t"
 
Old 12-20-2009, 12:32 PM   #6
isolatedsh33p
LQ Newbie
 
Registered: Dec 2009
Posts: 9

Rep: Reputation: 1
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.
 
Old 12-21-2009, 01:56 AM   #7
DrLove73
Senior Member
 
Registered: Sep 2009
Location: Srbobran, Serbia
Distribution: CentOS 5.5 i386 & x86_64
Posts: 1,118
Blog Entries: 1

Rep: Reputation: 129Reputation: 129
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.
 
Old 12-21-2009, 02:33 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,544
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by DrLove73 View Post
Truth to be told, Gnome is designed for small memory and CPU requirements.
An interesting perspective; do you have any references to support it?
 
Old 12-21-2009, 03:32 AM   #9
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Original Poster
Rep: Reputation: 47
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'.

how can i accomplish that ?
 
Old 12-21-2009, 04:07 AM   #10
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,544
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Any particular reason you don't want to use Wallpaper Tray to do the job?
 
Old 12-21-2009, 04:51 AM   #11
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Original Poster
Rep: Reputation: 47
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.
 
Old 12-21-2009, 06:11 AM   #12
isolatedsh33p
LQ Newbie
 
Registered: Dec 2009
Posts: 9

Rep: Reputation: 1
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.
 
Old 12-21-2009, 09:32 AM   #13
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Original Poster
Rep: Reputation: 47
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.
 
Old 12-21-2009, 09:42 AM   #14
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,544
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by sumeet inani View Post
But I like to use command & am also learning bash scripting.
That's cool
 
Old 12-21-2009, 09:47 AM   #15
linus72
Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: PocketWriter/MinimalX
Posts: 5,058

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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

oh I got it at my site

TC_OKAJIMA_20090514.ISO (11MB)
http://multidistro.com/downloads/por...A_20090514.ISO

heres a usb version I made from updated tinycore iso and has extra apps too
73MB
http://multidistro.com/downloads/off...0090514.tar.gz

Quote:
Tinycore-2.0rc1-OKAJIMA-20090514-USB.tar.gz

Has apps like the others, but is based off TC-2.0rc1 hacked by the Honorable Mr Okajima!
and has a "Session-save" for CD-R ( http://www.digitalinfra.co.jp/20090514/tc_save.html ), also referenced here-
( http://tinycorelinux.com/forum/index..._next=prev#new )
The download also includes the "TC_OKAJIMA_20090514.iso" by Mr. Okajima.
http://www.digitalinfra.co.jp/20090514/tc_save.html


play it on qemu,etc or put it on usb or hd and at each boot the color is different
 
0 members found this post helpful.
  


Reply

Tags
software, wallpaper


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't change wallpaper w/ openbox / how to change mousespeed johnnyxxxcakes Linux - Newbie 14 05-24-2009 07:11 PM
change wallpaper? matrixon Linux - Software 1 06-12-2006 03:20 AM
Wallpaper Won't change Rick069 Linux - Newbie 3 04-16-2006 01:03 PM
How to change wallpaper pacranch Amigo 9 06-27-2005 01:30 PM
change wallpaper TravisB Linux - General 4 10-23-2002 05:57 PM


All times are GMT -5. The time now is 02:17 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration