breakManager: Add new state machine for screen time/health breaks
This implements health break reminder support in gnome-shell. It depends on a few bits and bobs from other modules: - New settings schemas in gsettings-desktop-schemas (released in 47.beta, which Mutter already depends on) - 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 `BreakManager`, which is a state machine which uses the Mutter `IdleMonitor` to track whether the user is, or should be, in a screen time break. The `BreakDispatcher` is based on top of this, and controls showing notifications, countdown timers, screen fades, the lock shield, etc. to make the user aware of upcoming or due breaks, as per their notification preferences. Unit tests are included to check that `BreakManager` works. These provide mock implementations of basic GLib clock functions, the `IdleMonitor` and `Gio.Settings` in order to test the state machine in faster-than-real-time. Signed-off-by: Philip Withnall <pwithnall@gnome.org> See: https://gitlab.gnome.org/Teams/Design/initiatives/-/issues/130 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3251>
This commit is contained in:
@ -15,6 +15,7 @@ import {ControlsState} from './overviewControls.js';
|
||||
|
||||
const GnomeShellIface = loadInterfaceXML('org.gnome.Shell');
|
||||
const ScreenSaverIface = loadInterfaceXML('org.gnome.ScreenSaver');
|
||||
const ScreenTimeIface = loadInterfaceXML('org.gnome.Shell.ScreenTime');
|
||||
|
||||
export class GnomeShell {
|
||||
constructor() {
|
||||
@ -542,3 +543,30 @@ export class ScreenSaverDBus {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class ScreenTimeDBus {
|
||||
constructor(breakManager) {
|
||||
this._manager = breakManager;
|
||||
|
||||
this._manager.connect('notify::state', this._onNotify.bind(this));
|
||||
this._manager.connect('notify::last-break-end-time', this._onNotify.bind(this));
|
||||
|
||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenTimeIface, this);
|
||||
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell/ScreenTime');
|
||||
}
|
||||
|
||||
_onNotify() {
|
||||
// We always want to notify the two properties together, as clients need
|
||||
// both values to be useful. GJS will combine the two emissions for us.
|
||||
this._dbusImpl.emit_property_changed('State', new GLib.Variant('u', this.State));
|
||||
this._dbusImpl.emit_property_changed('LastBreakEndTime', new GLib.Variant('t', this.LastBreakEndTime));
|
||||
}
|
||||
|
||||
get State() {
|
||||
return this._manager.state;
|
||||
}
|
||||
|
||||
get LastBreakEndTime() {
|
||||
return this._manager.lastBreakEndTime;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user