After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 597030 - support automatic logout after a maximum period of idleness
support automatic logout after a maximum period of idleness
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: power
3.7.x
Other Linux
: Normal normal
: ---
Assigned To: Richard Hughes
gnome-settings-daemon-maint
Depends on:
Blocks: 597127 599258
 
 
Reported: 2009-10-01 18:51 UTC by William Jon McCann
Modified: 2013-01-25 15:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (19.16 KB, patch)
2009-10-02 15:00 UTC, William Jon McCann
none Details | Review
updated patch (22.95 KB, patch)
2009-10-22 02:58 UTC, William Jon McCann
needs-work Details | Review
updated patch (22.87 KB, patch)
2010-11-02 15:57 UTC, Matthias Clasen
none Details | Review
Support automatic logout after a maximum period of idleness (16.71 KB, patch)
2012-12-11 22:44 UTC, Matthias Clasen
committed Details | Review
power: Support automatic logout after a maximum period of idleness (2.94 KB, patch)
2012-12-13 10:55 UTC, Bastien Nocera
reviewed Details | Review
Revert "Support automatic logout after a maximum period of idleness" (16.56 KB, patch)
2013-01-23 12:15 UTC, Bastien Nocera
committed Details | Review
power: Support automatic logout after a maximum period of idleness (5.44 KB, patch)
2013-01-24 08:40 UTC, Bastien Nocera
none Details | Review
power: Support automatic logout after a maximum period of idleness (13.34 KB, patch)
2013-01-25 15:42 UTC, Bastien Nocera
committed Details | Review
power: Add tests for the logout on idle feature (5.12 KB, patch)
2013-01-25 15:43 UTC, Bastien Nocera
committed Details | Review

Description William Jon McCann 2009-10-01 18:51:51 UTC
Something I've wanted to do for a while is support automatic logout after a maximum period of idleness.

Since the session and xorg are responsible for detecting idleness in the first place there really isn't much point in putting the max-idle enforcement mechanism outside the session.  If the user really wants to get around the restriction they can send virtual keystrokes to xorg every second or two - or worse...

So, a simple approach is to just start counting after the session goes idle, show a warning (or set of warnings) before the action, and then use the same logout path we use on a forced logout.  If the logout gets stuck at any point during a forced logout that should be considered a bug and doesn't follow the gnome session spec.

In the case where the screen isn't locked we should show some warnings - perhaps in the form of notification bubbles - that the session is about to end.  If the screen is locked then the screensaver needs to show these same messages.  When the screen is not locked, any user input should reset the idle counter and mark the user as availble- and not logout.  If the screen is locked we require the user to unlock the screen (authenticate) in order to be authorized to reset the idle state and cancel the impending logout.

Since logout is not the only possible action that may occur after a maximum-idle-time we should allow for adding these in the future.  One can imagine doing a "disconnect" in the case of a terminal server for example.

Since there may be logout inhibitors in place.  We should probably have separate actions for a logout that honors them and that doesn't.  Perhaps, "logout" and "forced-logout".

For similar reasons, we may also want to have a gconf key that ignores idle inhibitors.  However, as pointed out above this isn't really something that can force the user since passive presence detection is pretty weak - but it may be valuable if there are badly behaving applications.

We should consider if it would make sense to have a "suspend" action or similar.

A related but separate feature would be to add a maximum-login-time property that would force logouts after a certain time after login.  Perhaps useful for timed kiosks.
Comment 1 Colin Walters 2009-10-01 20:02:52 UTC
What's the motivation here?  Fast user switching?  My friend comes in logs into the guest account, opens 30 firefox tabs, then I fast user switch back and his websites stay open eating lots of resources?

I understand the kiosk case.  But for the mobile case I'd *far* prefer suspend-by-default (or the status quo) at least in the single user case.
Comment 2 William Jon McCann 2009-10-01 21:08:39 UTC
Very commonly requested anywhere that has shared resources: servers, labs, etc.  Would not be enabled by default.
Comment 3 William Jon McCann 2009-10-02 15:00:38 UTC
Created attachment 144599 [details] [review]
patch
Comment 4 Colin Walters 2009-10-02 15:58:20 UTC
Ok, makes sense to me =)
Comment 5 Matthias Clasen 2009-10-03 00:24:47 UTC
Patch works fine in my testing.
Comment 6 William Jon McCann 2009-10-22 02:58:15 UTC
Created attachment 146014 [details] [review]
updated patch
Comment 7 Lucas Rocha 2009-11-12 00:33:32 UTC
Review of attachment 146014 [details] [review]:

Looks good to me otherwise.

::: configure.in
@@ +56,3 @@
         devkit-power-gobject >= $DEVKIT_POWER_REQUIRED
         dbus-glib-1 >= $DBUS_GLIB_REQUIRED
+        libnotify >= $LIBNOTIFY_REQUIRED

Hmm, not really happy with adding a dependency on libnotify. Well, it's a blessed dep on GNOME so maybe it's ok.

::: gnome-session/gsm-manager.c
@@ +71,3 @@
+#define GS_INTERFACE "org.gnome.ScreenSaver"
+#define GS_PATH      "/org/gnome/ScreenSaver"
+#define GS_NAME      "org.gnome.ScreenSaver"

The "GS" prefix doesn't say much here. Maybe "SCREENSAVER_" or something more explicit instead?

@@ +174,3 @@
+        ACTION_LOGOUT,
+        ACTION_NONE = 0,
+typedef enum {

Should probably be MaxIdleAction. And MAX_IDLE_ACTION_NONE, MAX_IDLE_ACTION_LOGOUT, MAX_IDLE_ACTION_FORCED_LOGOUT. For clarity reasons.

@@ +2443,3 @@
+                manager->priv->max_idle_warning_timeout_id = 0;
+        }
+

Destroy/close notification here?

@@ +2524,3 @@
+        char *summary;
+        char *body;
+        char *remaining;

Align variables following the coding style of the rest of this file.

@@ +2573,3 @@
+                                                    NULL);
+                } else {
+                        manager->priv->max_idle_notification

move '=' to end of previous line.

@@ +2627,3 @@
+        warn_secs = 0.05 * manager->priv->max_idle_time_secs;
+        manager->priv->max_idle_warning_timeout_id
+                = g_timeout_add_seconds (warn_secs,

move the '=' to the end of previous line.

@@ +2644,3 @@
+        warn_secs = 0.1 * manager->priv->max_idle_time_secs;
+        manager->priv->max_idle_warning_timeout_id
+                = g_timeout_add_seconds (warn_secs,

move the '=' to the end of previous line.

@@ +2656,3 @@
+
+static void
+reset_max_idle_timer (GsmManager  *manager)

Maybe a better same for this function would be "maybe_reset_max_idle_timer".

@@ +2662,3 @@
+        g_object_get (manager->priv->presence, "status", &status, NULL);
+
+

Remove this extra blank line.

@@ +2683,3 @@
+
+                manager->priv->max_idle_timeout_id
+                        = g_timeout_add_seconds (manager->priv->max_idle_time_secs,

move the '=' to the end of previous line.

@@ +2690,3 @@
+                warn_secs = 0.8 * manager->priv->max_idle_time_secs;
+                manager->priv->max_idle_warning_timeout_id
+                        = g_timeout_add_seconds (warn_secs,

move the '=' to the end of previous line.

@@ +2746,3 @@
+                                manager->priv->max_idle_action = ACTION_NONE;
+                        }
+                        reset_max_idle_timer (manager);

It's a bit strange that changing the action resets the timer. Any specific reasons for doing it?
Comment 8 Lucas Rocha 2009-11-12 00:33:33 UTC
Review of attachment 146014 [details] [review]:

Looks good to me otherwise.

::: configure.in
@@ +56,3 @@
         devkit-power-gobject >= $DEVKIT_POWER_REQUIRED
         dbus-glib-1 >= $DBUS_GLIB_REQUIRED
+        libnotify >= $LIBNOTIFY_REQUIRED

Hmm, not really happy with adding a dependency on libnotify. Well, it's a blessed dep on GNOME so maybe it's ok.

::: gnome-session/gsm-manager.c
@@ +71,3 @@
+#define GS_INTERFACE "org.gnome.ScreenSaver"
+#define GS_PATH      "/org/gnome/ScreenSaver"
+#define GS_NAME      "org.gnome.ScreenSaver"

The "GS" prefix doesn't say much here. Maybe "SCREENSAVER_" or something more explicit instead?

@@ +174,3 @@
+        ACTION_LOGOUT,
+        ACTION_NONE = 0,
+typedef enum {

Should probably be MaxIdleAction. And MAX_IDLE_ACTION_NONE, MAX_IDLE_ACTION_LOGOUT, MAX_IDLE_ACTION_FORCED_LOGOUT. For clarity reasons.

@@ +2443,3 @@
+                manager->priv->max_idle_warning_timeout_id = 0;
+        }
+

Destroy/close notification here?

@@ +2524,3 @@
+        char *summary;
+        char *body;
+        char *remaining;

Align variables following the coding style of the rest of this file.

@@ +2573,3 @@
+                                                    NULL);
+                } else {
+                        manager->priv->max_idle_notification

move '=' to end of previous line.

@@ +2627,3 @@
+        warn_secs = 0.05 * manager->priv->max_idle_time_secs;
+        manager->priv->max_idle_warning_timeout_id
+                = g_timeout_add_seconds (warn_secs,

move the '=' to the end of previous line.

@@ +2644,3 @@
+        warn_secs = 0.1 * manager->priv->max_idle_time_secs;
+        manager->priv->max_idle_warning_timeout_id
+                = g_timeout_add_seconds (warn_secs,

move the '=' to the end of previous line.

@@ +2656,3 @@
+
+static void
+reset_max_idle_timer (GsmManager  *manager)

Maybe a better same for this function would be "maybe_reset_max_idle_timer".

@@ +2662,3 @@
+        g_object_get (manager->priv->presence, "status", &status, NULL);
+
+

Remove this extra blank line.

@@ +2683,3 @@
+
+                manager->priv->max_idle_timeout_id
+                        = g_timeout_add_seconds (manager->priv->max_idle_time_secs,

move the '=' to the end of previous line.

@@ +2690,3 @@
+                warn_secs = 0.8 * manager->priv->max_idle_time_secs;
+                manager->priv->max_idle_warning_timeout_id
+                        = g_timeout_add_seconds (warn_secs,

move the '=' to the end of previous line.

@@ +2746,3 @@
+                        }
+                        reset_max_idle_timer (manager);
+        } else if (strcmp (key, KEY_MAX_IDLE_TIME) == 0) {

It's a bit strange that changing the action resets the timer. Any specific reasons for doing it?
Comment 9 Matthias Clasen 2010-11-02 15:57:03 UTC
Created attachment 173699 [details] [review]
updated patch

Here is an update of the patch that works with libnotify 0.7
Comment 10 Matthias Clasen 2011-08-27 04:32:18 UTC
How about getting this landed for 3.2 ?
Comment 11 James 2012-10-09 12:28:20 UTC
Hi there,

I've written something that does this and have spoken to gnome devs about it before. It's probably much more than the gnome devs want, because it is targeted specifically for large computer labs, and sysadmins, but have a look if you're interested.

The project is called "evanescent" and the code is available here: http://cs.mcgill.ca/~james/code/

Note: this is my old website, new website is: https://ttboj.wordpress.com/

Hope this is useful to you, if anything you might get some design ideas, and I have experience implementing this in a 300?+ computer setup.

James
Comment 12 Matthias Clasen 2012-12-11 22:44:48 UTC
Created attachment 231311 [details] [review]
Support automatic logout after a maximum period of idleness

This is very commonly requested in any situation with
shared resources: servers, labs, etc.

We simply start counting down once the session goes idle,
and display a warning notification when we get close to the
maximum allowed idle time.

The feature is controlled by two new org.gnome.SessionManager
settings: max-idle-time and max-idle-action. The time is specified
in minutes, and the action can be 'none', 'logout' or 'force-logout',
with 'none' being the default.

This commit adds a libnotify dependency.

http://bugzilla.gnome.org/show_bug.cgi?id=597030
Comment 13 Colin Walters 2012-12-12 15:18:14 UTC
Review of attachment 231311 [details] [review]:

The code looks OK.

Matthias and I had a quick in person chat about this patch.  My concern was mainly about potential for bad interaction with the lockscreen - for example, at the moment we pop up the end session dialog on top, which is suboptimal at least.  

Using libnotify - OK for now, the longer term solution is likely that this functionality is integrated into the shell (e.g. the lockscreen dialog knows how to show "you are about to be logged out" on its own).
Comment 14 Matthias Clasen 2012-12-12 16:40:11 UTC
Attachment 231311 [details] pushed as 7d0e8ae - Support automatic logout after a maximum period of idleness
Comment 15 Bastien Nocera 2012-12-13 10:51:34 UTC
Why do we do that in gnome-session?
We already have a mechanism for handling "what to do" on idle in gnome-settings-daemon's power plugin.

Adding support for closing the session would have meant:
- adding a new enum member (or 2) to org.gnome.settings-daemon.GsdPowerActionType
- adding support for calling out to gnome-session when sleep-inactive-ac-type or sleep-inactive-battery-type is hit.

It means we don't need yet another idle in a separate code path.
Comment 16 Bastien Nocera 2012-12-13 10:55:02 UTC
Created attachment 231462 [details] [review]
power: Support automatic logout after a maximum period of idleness

This is very commonly requested in any situation with
shared resources: servers, labs, etc.

We simply show the log out dialog once the session goes idle.

The feature is controlled by the sleep-inactive-*-timeout and
sleep-inactive-*-type keys.

http://bugzilla.gnome.org/show_bug.cgi?id=597030
Comment 17 Ray Strode [halfline] 2012-12-13 16:19:06 UTC
Review of attachment 231462 [details] [review]:

makes sense to me.  We should revert the other bit and use this instead.

::: plugins/power/gsd-power-manager.c
@@ +2039,3 @@
+gnome_session_logout_cb (GObject *source_object,
+                         GAsyncResult *res,
+                         gpointer user_data)

you don't line up arguments here, but do in gnome_session_logout

@@ +2158,3 @@
+                break;
+        case GSD_POWER_ACTION_FORCE_LOGOUT:
+                gnome_session_logout (manager, 2);

might be better to have #defines for the logout mode
Comment 18 Bastien Nocera 2012-12-13 16:23:45 UTC
Note that it's completely untested, and doesn't have any of the nice GUI features that Matthias added to his version.
The "we're about to logout" is implemented through the logout dialog that will countdown from 60 seconds.
Comment 19 Ray Strode [halfline] 2012-12-13 19:24:26 UTC
I guess ideally we'd have some information in the dialog saying when it popped up.

Though, thinking about this more.  We generally don't like showing modal dialogs out of the blue, so just popping up the logout dialog might not be great idea.

Not sure libnotify is awesome either.  maybe we need a slow fade like screensaver has.
Comment 20 Bastien Nocera 2013-01-19 14:01:51 UTC
I've encountered the original code again, and I'm not sure it works as expected:
in on_presence_status_changed():
        system = gsm_get_system ();
        gsm_system_set_session_idle (system,
                                     (status == GSM_PRESENCE_STATUS_IDLE));
        g_object_unref (system);

        reset_max_idle_timer (manager);

Looks like the timer is reset when we go *to* idle, so a 5 minutes idle-delay with a 10 minutes max-idle actually turns into a 15 minutes max-idle.

Can we get some comments on the "UI" (or lack thereof) of the gnome-settings-daemon implementation? Should we add similar warning notifications to gnome-settings-daemon? (which would allow us to enable automatic suspend on idle, maybe).
Comment 21 Matthias Clasen 2013-01-20 20:08:12 UTC
(In reply to comment #18)
> Note that it's completely untested, and doesn't have any of the nice GUI
> features that Matthias added to his version.

The UI is certainly an important part of this - lets not drop it on the floor.
Comment 22 Bastien Nocera 2013-01-23 12:15:36 UTC
Created attachment 234181 [details] [review]
Revert "Support automatic logout after a maximum period of idleness"

This reverts commit 7d0e8aed1590eaa8caa7666a388eadb8182ac244.

The functionality should be implemented in gnome-settings-daemon
instead, using the already present "sleep-inactive-*-timeout" as the max
idle value, with GSD_POWER_ACTION_INTERACTIVE as the
"sleep-inactive-*-type".

Notification is still missing compared to the gnome-session feature.

http://bugzilla.gnome.org/show_bug.cgi?id=597030
Comment 23 Bastien Nocera 2013-01-23 12:16:18 UTC
Comment on attachment 234181 [details] [review]
Revert "Support automatic logout after a maximum period of idleness"

Attachment 234181 [details] pushed as ddd49c7 - Revert "Support automatic logout after a maximum period of idleness"
Comment 24 Bastien Nocera 2013-01-24 08:40:17 UTC
Created attachment 234286 [details] [review]
power: Support automatic logout after a maximum period of idleness

This is very commonly requested in any situation with
shared resources: servers, labs, etc.

We either log out, or force the logout when the maximum idle time
has been detected.

The feature is controlled by the sleep-inactive-*-timeout and
sleep-inactive-*-type keys.

http://bugzilla.gnome.org/show_bug.cgi?id=597030
Comment 25 Bastien Nocera 2013-01-25 15:42:59 UTC
Created attachment 234417 [details] [review]
power: Support automatic logout after a maximum period of idleness

This is very commonly requested in any situation with
shared resources: servers, labs, etc.

We either log out, or force the logout when the maximum idle time
has been detected.

The feature is controlled by the sleep-inactive-*-timeout and
sleep-inactive-*-type keys.

http://bugzilla.gnome.org/show_bug.cgi?id=597030
Comment 26 Bastien Nocera 2013-01-25 15:43:12 UTC
Created attachment 234418 [details] [review]
power: Add tests for the logout on idle feature
Comment 27 Bastien Nocera 2013-01-25 15:44:40 UTC
Attachment 234417 [details] pushed as 5edebf4 - power: Support automatic logout after a maximum period of idleness