[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: shutdown-at-night kicked me off



On 29/08/13 22:13, Petter Reinholdtsen wrote:
>     if [ "$(who)" ] ||  ps -efwww | egrep -q ' ssh .*LTSP_CLIEN[T]' ; then

> Is it not working as it should?  Any ideas how to improve it?

On a wheezy XFCE desktop, I only see 'who' entries for any terminal
windows I might have open.  Otherwise I don't see an entry for the
graphical desktop session itself.

The laziest I can think of right now is:
	if pgrep '^xfce4-session$'; then return 1; fi
but someone should check if other desktops need this too.

Otherwise I think ConsoleKit is the more... formal way to code something
like this.

http://www.freedesktop.org/software/ConsoleKit/doc/ConsoleKit.html#dbus-reference

There is a GetSystemIdleHint, but unfortunately my idle XFCE session
with Xscreensaver running doesn't seem to register as idle after waiting
5 minutes.  If only that worked, GetSystemIdleTimeHint would have
allowed for something even better:  'shut down if all sessions have been
idle for an hour or more' (and you could execute the cron job hourly,
all night).

# dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit
/org/freedesktop/ConsoleKit/Manager
org.freedesktop.ConsoleKit.Manager.GetSystemIdleHint | grep 'true$'

This may be still useful though:  if there are no sessions at all, it
should return 'true';  if it doesn't, at least we know someone is logged
in (idle or not) and can avoid shutting down the machine.

> if ! dbus-send --system --print-reply \
>     --dest=org.freedesktop.ConsoleKit \
>     /org/freedesktop/ConsoleKit/Manager\
>     org.freedesktop.ConsoleKit.Manager.GetSystemIdleHint \
>     | grep 'true$'; then
>         return 1
> fi

Regards,
-- 
Steven Chamberlain
steven@pyro.eu.org


Reply to: