-
My Script does not die when I logout
I have a couple of scripts I use to change my desktop background every 10 minutes. setback2
#!/bin/bash
number=$RANDOM
let "number2=number*50/32767"
image=~/images/$number2.jpg
echo $image > .screen.img
if [ -x /usr/bin/X11/xv ] && [ -e $image ]
then
/usr/bin/X11/xv -maxp -quit -root $image
fi
randomly sets the background and setback3
#! /bin/bash
let "PID=$$"
echo $PID > .pidfile.image
while [ true ]
do
~/bin/setback2
sleep 600
done
sets the background every 10 minutes.
My problem is that setback3 does not die when I log out.
I have setback3 in my session startup. Is there a better way of doing this.
Thanks for any help.
AMD Athlon 1.3 Ghz
Fedora Core 1
512 MB RAM
Nvida Riva TNT2 Video Card
-
Are you starting the script with exec, or just putting the path/script on a line by itself in your .xinitrc? If you use exec it should terminate when the X session ends.
Code:
exec /path/to/your/scripts
-
Actually I am using the gome session manager to start the script for me when I login. I will try using the xinitrc file and see what happens.
Thanks
AMD Athlon 1.3 Ghz
Fedora Core 1
512 MB RAM
Nvida Riva TNT2 Video Card
-
.xinitrc does not seem to work with gnome. How else does Gnome initialize its startup scripts?
AMD Athlon 1.3 Ghz
Fedora Core 1
512 MB RAM
Nvida Riva TNT2 Video Card
-
assuming this gets started by the process that connects X -
change the loop at the bottom
Code:
while [ true ]
do
~/bin/setback2
ps - p $PPID >/dev/null 2>/dev/null
if [ $? -eq 1 ] ; then
exit;
fi
sleep 600
done
$PPID is the parent pid of the process - ps fails if the pid does not exist.
-
Don't do it as a pair of scripts.
Do it using cron. Create a cron job that runs every 10 minutes. In the script that you run, first check to see that Gnome is running, then if it is, do your xv thing.
ps -C gnome-session >/dev/null && /usr/X11R6/bin/xv -options will do this, with Linux's ps program. No ifs needed.
-
Thanks for the replies. Unfortunately it still does not work. I already had tried cron and it complained about not finding the current display.
The $PPID was almost there! But the session startup menu kills itself I think so the process dies too. I have no clue about that.
Back to the drawing board for me!
AMD Athlon 1.3 Ghz
Fedora Core 1
512 MB RAM
Nvida Riva TNT2 Video Card
-
I think I have it finally. I used bwkaz's idea of ps -C gnome-session and jim's idea of exiting when some conditin fails together to give me my cool desktop which changes every 10 minutes!
#! /bin/bash
let "PID=$$"
echo $PID > .pidfile.image
#while [ 1 -lt 2 ]
while [ true ]
do
~/bin/setback2
ps -C gnome-session >/dev/null 2>/dev/null
if [ $? -eq 1 ] ; then
exit;
fi
sleep 600
done
Now that I have my desktop configured maybe i will actually do some work!!!
AMD Athlon 1.3 Ghz
Fedora Core 1
512 MB RAM
Nvida Riva TNT2 Video Card
-
Originally posted by funnyjedi
I already had tried cron and it complained about not finding the current display.
Oh... I bet that's because cron jobs are run in non-interactive shells (i.e., shells that don't read either ~/.bash_profile or ~/.bashrc). If you export DISPLAY=:0.0 at the beginning of the script, that ought to help.
Not that it matters, since you got it working anyway, but IMHO it's cleaner to do it in one script.
*shrug*
-
As a personal choice I prefer one script too. I will try this one since it seems cleaner than using two. Thanks for the tip.
It works! That is pretty cool. Thanks.
Last edited by funnyjedi; 11-10-2003 at 09:21 AM.
AMD Athlon 1.3 Ghz
Fedora Core 1
512 MB RAM
Nvida Riva TNT2 Video Card
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|