Am Samstag 12 Juli 2008 schrieb Nigel Cunningham:
> Hi.
Hi Nigel,
> On Tue, 2008-07-08 at 09:08 +0200, Martin Steigerwald wrote:
> > Hi!
> >
> > Recently I thought about user scriptlets in hibernate... it would be
> > nice to be able to store scriptlets in ~/.hibernate that do
> > communication with applications that run with the own user.
> >
> > I had this idea first as I got a new USB soundcard which likes
> > unloading of usb sound module so that it resumes nicely. Prior to
> > that I would like to stop Amarok and restart it on resume to avoid
> > any issue with Amarok / xine finding its sound device disappearing
> > suddenly.
> >
> > What do you think?
> >
> > I think these should be executed before any system-related
> > scriptlets.
>
> It's certainly a possibility. How would you envisage the hibernate
> script determining which users' home directories to check?
First very naive approach to be improved upon or replaced with something
better:
martin@shambala> who
martin :0 2008-07-11 15:16
ms :1 2008-07-12 13:23
martin@shambala> who | grep ":[0-9]" | cut -d" " -f 1 | sort | uniq
martin
ms
This doesn't catch SSH logins with X forwarding... but then when I think
about it more thoroughly why should it be restricted to X11 at all.
Just call scriptlets for all currently logged in users:
martin@deepdance:~> who
martin :0 2008-07-04 21:46
martin pts/8 2008-07-11 15:20 (shambala)
martin pts/9 2008-07-12 13:25 (shambala)
martin@deepdance:~> who | cut -d" " -f 1 | sort | uniq
martin
And document that the script has to check itself for failed display
variable...
Even for SSH logins someone might come up with something useful (like
killing those ssh sessions instead of leaving the endpoints with stalled
connections).
hibernate should make sure that $USER is set correctly when calling a
userspace scriptlet - if this is not done automatically. Also $DISPLAY
should be set correctly.
The script could then do:
martin@shambala> ( echo $DISPLAY | grep -q "^:[0-9]" ) && echo "Stopping
Amarok for $USER"
Stopping Amarok for martin
(could be in a user scriptlet template)
Hmmm, I could setup some testcase for this I think... just a small root
scriptlet that does "su" on "who | cut -d" " -f 1 | sort | uniq" and a
small user scriptlet like the one above...
But first I wait for feedback whether you think that it could actually
work that way.
Ciao,
--
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA B82F 991B EAAC A599 84C7