Pre-Logout Script

houghi houghi at houghi.org
Sun Nov 18 20:04:19 CET 2012


On Sun, Nov 18, 2012 at 06:57:18PM +0100, Erik Habicht wrote:
> thank you for your research and the simple working solution. I tried it
> out and it works as expected. But i implement it a little bit different.
> Instead of moving the /usr/bin/xfce4-session to
> /usr/bin/xfce4-session.orig i add a /usr/local/bin/xfce4-session that
> invoke /usr/bin/xfce4-session.

That is better as renaming and moving default stuff around is not such a
good idea.

> In the meantime i worked out another solution. It's the more native way,
> but not so simple. I add a system call to xfce4-session/xfsm-manager.c
> that runs 'run-parts /etc/xfce/pre-logout.d'. The patch is not ready for
> production but it works.
> I think running a shell script as you said instead of use run-parts
> could be the better solution since run-parts is not part of all
> distribution.

openSUSE does not have it.

> This is the code that runs pre logout:
> 
> killall -TERM vmplayer

Doesn't vmplayer have a native command to do just that? I do not use
vmplayer as I use VirtualBox, so I have no idea if it is possible.

>From what I found a good place to start is `vmrun -T player list`, find
the vmx('s) that are running and then in a loop kill them. e.g.

for I in `vmrun -T player list|<something to get the vmx full path>`
do
	vmrun stop $I
done

Obviously this might take a bit more time then just killing it, but it
might also prevent problems with VM when you just kill it. You could also
suspend it instead of stopping it:
http://www.vmware.com/support/ws5/doc/ws_learning_cli_vmrun.html
gives more info.

Under Virtualbox this would be:
for I in `VBoxManage list -l runningvms|grep ^UUID|awk '{print $NF}'`
do
	VBoxManage controlvm $I poweroff
done

houghi
-- 
Nutze die Zeit. Sie ist das Kostbarste, was wir haben, denn
es  ist unwiederbringliche Lebenszeit.  Leben ist aber mehr
als Werk und Arbeit, und das Sein wichtiger als das Tun.
                                    - Johannes Muller-Elmau


More information about the Xfce mailing list