LinuxQuestions.org
Review your favorite Linux distribution.
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-21-2009, 09:52 AM   #16
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79

sumeet inani: this is great, although I suggest /tmp/int.txt instead of ~/int.txt, since any good desktop distro will wipe out /tmp at each boot, unless you want it to be persistent and user specific, in which case I would suggest to name your file ~/.int.txt so it doesn't appear in nautilus. Check if the file exist and create it with 0 if it does not.
 
Old 12-21-2009, 12:14 PM   #17
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
Quote:
Originally Posted by catkin View Post
An interesting perspective; do you have any references to support it?
I have not meant it as an absolute. There are WM's with much lesser requirements, but if you compare two mayor WM's, KDE and GNOME, you must agree that GNOME project is striving to minimalistic design as much as possible. Of course, with new powerful hardware and average hardware replacement cycle of 3-5 years, they allow larger and large requirements, but I still believe withing lower standards.

Last edited by DrLove73; 12-21-2009 at 12:19 PM.
 
Old 12-21-2009, 12:40 PM   #18
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,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by DrLove73 View Post
I have not meant it as an absolute. There are WM's with much lesser requirements, but if you compare two mayor WM's, KDE and GNOME, you must agree that GNOME project is striving to minimalistic design as much as possible. Of course, with new powerful hardware and average hardware replacement cycle of 3-5 years, they allow larger and large requirements, but I still believe withing lower standards.
Thanks DrLove73 IDK KDE but am happy to take you at your word -- that in a field of Gnome and KDE, Gnome is the lighter.
 
Old 12-21-2009, 10:48 PM   #19
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Original Poster
Rep: Reputation: 47
To agrouf
I want to store variable in file permanently so that even after shutdown when I reboot I will get next wallpaper.I don't like random function because there are chances of repeat & to prevent repeatition script will become complicated
But my query still remains unsolved
i will reiterate my method
integer variable's value is stored in file so that its value will be permanently stored.
~/.int.txt(created by us before putting script in cron) initially contains 0[improved filename suggested by agrouf]
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.

My problem is which command to use to give a file as input to integer variable.
Can somebody write the script ?(because I am beginner so don't know much though I am reading tutorials to get a grasp)

Last edited by sumeet inani; 12-21-2009 at 10:52 PM.
 
Old 12-22-2009, 12:10 AM   #20
isolatedsh33p
LQ Newbie
 
Registered: Dec 2009
Posts: 9

Rep: Reputation: 1
Quote:
Originally Posted by sumeet inani View Post
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 ?
I never used crontab before, that's why I used loop. Anyway, how about this
Code:
i=`head ~/.int.txt` #get the content of the file

#if greater than 99, then sets back i to 0.
if [ $i -gt 99 ]; then
    let i=0
fi

wp_fn=$HOME/wp/$i.jpg #set the name of the wallpaper file

... Do commands to change the wallpaper ...

#after finished, increment the value of i
let i=i+1
#finally write it into int.txt
echo "$i" >~/.int.txt
If you figure out how to use crontab, please share the knowledge with me.

Last edited by isolatedsh33p; 12-22-2009 at 12:17 AM.
 
1 members found this post helpful.
Old 12-22-2009, 01:57 AM   #21
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Original Poster
Rep: Reputation: 47
to isolatedsh33p
Thank You.It worked with success

a few changes in your script
Insert following line to change wallpaper
Code:
gconftool-2 -t str -s /desktop/gnome/background/picture_filename $wp_fn
one mistake in your script
Also first line of script should be
#!/bin/bash
without this let i=i+1 gave error

what i liked is you have used $HOME so it becomes independent of username.
i think we could also do
wp_fn=~/wp/$i.jpg isn't it ?

i didn't notice any increase in memory utilization while script ran.

About crontab
Create job.cron file containig following
0,5,10,15,20,25,30,35,40,45,50,55 * * * * ~/wp-change-script
brief explanation
0,... are minutes here I have changed every 5 minutes(allowed values 0 to 59)
The * represent all values for hour(o-23),day of month(1-31),month(1-12) & day of week(1=monday to 7) respectively.
add the file to task scheduler using
crontab job.cron
and verify it using
crontab -l
NOTE that you should create an empty file /usr/lib/cron/cron.deny(from root) so that all users are allowed.

Question 1)can we output cpu usage pertcentage to a file for few minutes ?
Question 2)How can we add 'check if ~/.int.txt exists otherwise create it' to script ?.

Last edited by sumeet inani; 12-22-2009 at 09:28 AM.
 
Old 12-22-2009, 05:13 AM   #22
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Quote:
Originally Posted by sumeet inani View Post
I don't like random function because there are chances of repeat & to prevent repeatition script will become complicated
Well, it's a little more complicated but if you want to raise the challenge, there is a way to do that.
Basically, you setup a list of files and you randomly swap each element one by one. You can then use the random list and be sure no element is repeated in that list.
Anyway, even if you don't use random numbers, having a list of files may be handy if you don't want to have a special name for your files ($n.jpg) You could use any file that is in the $HOME/wp directory, even recursively.
Quote:
Originally Posted by sumeet inani View Post
About crontab
Create job.cron file containig following
0,5,10,15,20,25,30,35,40,45,50,55 * * * * ~/wp-change-script
Actually, you can use this simpler syntax:
*/5 * * * * ~/wp-change-script
It means every 5 minutes.
You can also use the crontab -e command to edit the crontab.
Quote:
Originally Posted by sumeet inani View Post
Question 1)can we output cpu usage pertcentage to a file for few minutes ?
You can get cpu usage with /proc/loadavg:
http://www.redhat.com/docs/manuals/e...c-loadavg.html
I don't think it will be affected by your script at all though. Your script asks gnome to load images from the disk. most of its time will be spent waiting for the disk, idle (unless you have very fast SSD)
Quote:
Originally Posted by sumeet inani View Post
Question 2)How can we add 'check if ~/.int.txt exists otherwise create it' to script ?.
Code:
if [ -e ~/.int.txt ]; then
   #do something
else
   #do something else
fi

Last edited by Agrouf; 12-22-2009 at 05:16 AM.
 
1 members found this post helpful.
Old 12-22-2009, 09:37 AM   #23
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Original Poster
Rep: Reputation: 47
Thank you agrouf for lot of info.

I mean in random how can we make sure that all files become wallpaper before repetition occurs ?
I think Suppose we pull out lines from ~/wp/link.txt where each line has path address of desired image.
I think for avoiding repetition we have to maintain atleast two arrays one of which contains file that have become wallpapers.Isn't it ?.Presently my level is amateur so too difficult for me.First i have to learn basics.Even this script written by isolatedsh33p.

I have noted that in ubuntu 9.04 the script does not change wallpaper.though the number in .int.txt was changing.
Why is that ?

Last edited by sumeet inani; 12-22-2009 at 09:38 AM.
 
Old 12-22-2009, 12:59 PM   #24
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Quote:
Originally Posted by sumeet inani View Post
I have noted that in ubuntu 9.04 the script does not change wallpaper.though the number in .int.txt was changing.
Why is that ?
Check that the gconf value indeed changed. You can do that with gconf-editor or gconftool-2
 
Old 12-23-2009, 02:15 AM   #25
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Original Poster
Rep: Reputation: 47
I ran
gconftool-2 -g /desktop/gnome/background/picture_filename
It stays at ~/wp/0.jpg
though
cat ~/.int.txt
7
This is puzzling because same script works well in ubuntu 8.04 & here it seems .int.txt gets edited but string does not.Also I checked mail then got no error message.
Can anybody spot error in script presented by isolatedsh33p ?(the first line should be #!/bin/bash already pointed out)

Last edited by sumeet inani; 12-23-2009 at 02:44 AM.
 
Old 12-23-2009, 03:51 AM   #26
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Did you try to execute the script by hand (outside of cron) to see if there are any errors?
 
Old 12-23-2009, 03:58 AM   #27
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Original Poster
Rep: Reputation: 47
yes in terminal
As son as i execute script wallpaper changes but when I put it in cron then .int.txt changes but string does not & hence wallpaper does not.
 
Old 12-23-2009, 04:00 AM   #28
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Linux Mint
Posts: 8,511

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
If you use cron, make sure to use the whole path to all the commands and files.
Cron has a limited PATH
 
Old 12-23-2009, 04:05 AM   #29
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Also, cron does not set the $HOME variable.
You should start the script with
Code:
export HOME=/home/myuser
 
Old 12-23-2009, 04:22 AM   #30
sumeet inani
Member
 
Registered: Oct 2008
Posts: 881
Blog Entries: 26

Original Poster
Rep: Reputation: 47
I did safest thing replaced $HOME & ~ by /home/lxuser but invain.

Any ubuntu user with >8.04 can try the script to see whether they get wallpaper changed automatically ?
 
  


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 11:19 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