From ff844a2a817133ca64efa4f2d3d0e4ce7247662b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 20 Mar 2020 12:42:04 +0100 Subject: [PATCH] main: Do not warn about missing GDM on each login We now warn on startup if screen locking isn't available, however for users who choose not to use GDM or logind, repeating the warning on each login is more annoying than helpful. Instead, limit the warning to the first login on which the screen lock became unavailable. That way the notification will still serve the intended purpose of informing the user, but without being perceived as nagging. https://gitlab.gnome.org/GNOME/gnome-shell/issues/2432 --- js/ui/main.js | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/js/ui/main.js b/js/ui/main.js index b29360423..ebf9b333a 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -93,6 +93,9 @@ let _a11ySettings = null; let _themeResource = null; let _oskResource = null; +Gio._promisify(Gio._LocalFilePrototype, 'delete_async', 'delete_finish'); +Gio._promisify(Gio._LocalFilePrototype, 'touch_async', 'touch_finish'); + function _sessionUpdated() { if (sessionMode.isPrimary) _loadDefaultStylesheet(); @@ -276,11 +279,8 @@ function _initializeUI() { } if (sessionMode.currentMode !== 'gdm' && - sessionMode.currentMode !== 'initial-setup' && - screenShield === null) { - notify(_('Screen Lock disabled'), - _('Screen Locking requires the GNOME display manager.')); - } + sessionMode.currentMode !== 'initial-setup') + _handleLockScreenWarning(); LoginManager.registerSessionWithGDM(); @@ -293,6 +293,32 @@ function _initializeUI() { }); } +async function _handleLockScreenWarning() { + const path = '%s/lock-warning-shown'.format(global.userdatadir); + const file = Gio.File.new_for_path(path); + + const hasLockScreen = screenShield !== null; + if (hasLockScreen) { + try { + await file.delete_async(0, null); + } catch (e) { + if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND)) + logError(e); + } + } else { + try { + if (!await file.touch_async()) + return; + } catch (e) { + logError(e); + } + + notify( + _('Screen Lock disabled'), + _('Screen Locking requires the GNOME display manager.')); + } +} + function _getStylesheet(name) { let stylesheet;