Skip to content

timeLimitsManager: Add new state machine for screen time limits

Philip Withnall requested to merge pwithnall/gnome-shell:screen-time-limits into main

This implements wellbeing screen time limits in gnome-shell. It depends on a few changes in other modules:

  • New settings schemas in gsettings-desktop-schemas
  • A settings UI in gnome-control-center
  • User documentation in gnome-user-docs

It implements the design from https://gitlab.gnome.org/Teams/Design/settings-mockups/-/blob/master/wellbeing/wellbeing.png.

The core of the implementation is TimeLimitsManager, which is a state machine which uses the user’s session state from logind to track how long the user has been in an active session, in aggregate, during the day. If this total exceeds their limit for the day, the state machine changes state.

The user’s session activity history (basically, when they logged in and out for the past 14 weeks) is kept in a state file in their home directory. This is used by gnome-shell to count usage across reboots in a single day, and in the future it will also be used to provide usage history in gnome-control-center, so the user can visualise their historic computer usage at a high level, for the past several weeks.

The TimeLimitsDispatcher is based on top of this, and controls showing notifications and screen fades to make the user aware of whether they’ve used the computer for too long today, as per their preferences.

Unit tests are included to check that TimeLimitsManager works, in particular with its loading and storing of the history file. The unit tests provide mock implementations of basic GLib clock functions, the logind D-Bus proxy and Gio.Settings in order to test the state machine in faster-than-real-time.

Signed-off-by: Philip Withnall pwithnall@gnome.org

See: Teams/Design/initiatives#130

Merge request reports