[Tfug] Exiting a script when exiting X

Rich Smit rfsmit at gmail.com
Thu Dec 1 05:55:50 MST 2011


Gnome?
You really want the Xplanet session to be controlled by Gnome.

http://ubuntuforums.org/archive/index.php/t-49463.html
The poster says:

> start XPlanet when we log in:
> System > Preferences > Sessions
> Click on the "Startup Programs" tab, and click on "Add". Enter "xplanet"
> (without the quotes) into the "Startup Command" text box, and click OK.

Some of the responders offer scripts to do some extra stuff (skimmed, so I
don't know exactly what) -- if you use a script, then just have Gnome
launch the script instead of xplanet directly.

When Gnome exits, the script should exit too.
cheers,
Rich.

On Wed, Nov 30, 2011 at 20:50, John Gruenenfelder <jetpackjohn at gmail.com>wrote:

> Hello again,
>
> I'm a bit of an Xplanet junkie and I just finished updating my
> personal Xplanet scripts (to account for some changes in fetching the
> cloud map) which render the Earth and other bodies into a large
> wallpaper for my desktop.
>
> I've got it all working well now, as long as I'm actually running X.
> However, when I log out and the script times out (it sleeps for five
> minutes between updates), it doesn't know that I'm no longer logged in
> and will merrily continue with its work.  This becomes an even bigger
> problem if I then log back in within that five minute sleep period
> since the script will start again.
>
> I've partially solved the second issue by having a wrapper script use
> 'killall' on the actual render script to prevent two from running at
> the same time.  As long as the script is not currently doing work
> (i.e. it doesn't have currently executing child processes) this works
> fine.  If it *is* currently doing work, killall will just kill the
> parent script and not touch the child processes.  Not an elegant
> solution.  This appears to be a limitation of doing this process
> management non-interactively from a script.  I found yesterday, to my
> surprise, that if I run, say, "killall %2" from the bash prompt then
> the shell's job control logic will kill job 2 *and* its children.  At
> least, that's what it appeared to be doing.
>
> Does anybody know how I can work around these two problems?
>
> 1) When the script wakes up, detect that I'm not logged into an X
> session and cleanly exit.  I can't just naively grep "who" or some
> such; for example, what if I have a detached screen process in the
> background?  Alternatively, is there a way to have a script run on
> Gnome (or some other WM) shutdown that could kill the script for me?
> That leads to...
>
> 2) If the script does not exit by itself, how can I cleanly kill it
> from outside without leaving sad little orphans around?
>
> Right now, I just deal with the problem manually since I don't often
> log out and then log back in right away.  But it does happen, and it
> is annoying to have to kill all these things myself.
>
> BTW, if you are also an Xplanet aficionado, let me know and I'll make
> these handy scripts available.  Aside from running Xplanet, they also
> use some other tools to fetch the current cloud map, earthquakes,
> hurricanes, volcanoes, and satellite TLE data.  It's all very cool,
> very pretty, and a completely useless use of a small amount of CPU
> time every five minutes.  A big win all around.
>
>
> --
> --John Gruenenfelder    Systems Manager, MKS Imaging Technology, LLC.
> Try Weasel Reader for Palm OS  --  http://weaselreader.org
> "This is the most fun I've had without being drenched in the blood
> of my enemies!"
>         --Sam of Sam & Max
>
> _______________________________________________
> Tucson Free Unix Group - tfug at tfug.org
> Subscription Options:
> http://www.tfug.org/mailman/listinfo/tfug_tfug.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tfug.org/pipermail/tfug_tfug.org/attachments/20111201/83257557/attachment-0001.html>


More information about the tfug mailing list