Re: shutdown-at-night kicked me off
- To: email@example.com
- Subject: Re: shutdown-at-night kicked me off
- From: Steven Chamberlain <firstname.lastname@example.org>
- Date: Tue, 03 Sep 2013 21:36:00 +0100
- Message-id: <email@example.com>
- In-reply-to: <firstname.lastname@example.org>
- References: <CADLSRd5rOokxnTfZjCZNF9KU+w=9tPUzYyHWfHuw8aAL_j6email@example.com> <firstname.lastname@example.org>
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
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,
# dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit
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.GetSystemIdleHint \
> | grep 'true$'; then
> return 1