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
This commit is contained in:
Florian Müllner 2020-03-20 12:42:04 +01:00 committed by Florian Müllner
parent 78997cb7eb
commit ff844a2a81

View File

@ -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;