From: Ubuntu Developers Date: Thu, 11 Mar 2021 10:12:06 +0200 Subject: Allow configuring login screen background Configuring login screen backgound and properties is a recurring request especially on corporate environment. Allows to override the default embedded style in the theme with specific gsettings keys. Forwarded: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/680 Bug: https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/1918613 Origin: ubuntu --- data/com.ubuntu.login-screen.gschema.xml.in | 70 +++++++++++++++++++++++++++++ data/meson.build | 8 +++- js/ui/background.js | 4 ++ js/ui/screenShield.js | 37 +++++++++++++++ 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 data/com.ubuntu.login-screen.gschema.xml.in diff --git a/data/com.ubuntu.login-screen.gschema.xml.in b/data/com.ubuntu.login-screen.gschema.xml.in new file mode 100644 index 0000000..ee8b3a2 --- /dev/null +++ b/data/com.ubuntu.login-screen.gschema.xml.in @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + '' + + Sets the background image for the login screen. + + + URI to use for the background image. Note that the backend only + supports local (file://) URIs. + It overrides the value defined in the default style sheet. + + + + '' + + The background-color property sets the background color. + + + The background-color property sets the background color to use when + the background picture URI is missing or when it doesn't cover the whole background. + It overrides the value defined in the default style sheet. + + + + 'default' + + The background-repeat property sets if/how the background image will be repeated. + + + The background-repeat property sets if/how a background image will be repeated. + By default, a background-image is repeated both vertically and horizontally. + + It overrides the value defined in the default style sheet. + + + + 'default' + + The background-size property specifies the size of the background image. + + + The background-size property specifies the size of the background images. + + There are three keywords you can use with this property: + auto: The background image is displayed in its original size; + cover: Resize the background image to cover the entire container, even if it has to stretch the image or cut a little bit off one of the edges; + contain: Resize the background image to make sure the image is fully visible. + + It overrides the value defined in the default style sheet. + + + + diff --git a/data/meson.build b/data/meson.build index 30d4917..22d6665 100644 --- a/data/meson.build +++ b/data/meson.build @@ -95,6 +95,12 @@ schema = configure_file( configuration: schemaconf, install_dir: schemadir ) +schema_ubuntu_login = configure_file( + input: 'com.ubuntu.login-screen.gschema.xml.in', + output: 'com.ubuntu.login-screen.gschema.xml', + configuration: schemaconf, + install_dir: schemadir +) install_data('00_org.gnome.shell.gschema.override', install_dir: schemadir) overrides_migration_conf = configuration_data() @@ -132,7 +138,7 @@ endif # for unit tests - gnome.compile_schemas() only looks in srcdir custom_target('compile-schemas', - input: schema, + input: [schema, chema_ubuntu_login], output: 'gschemas.compiled', command: [find_program('glib-compile-schemas'), meson.current_build_dir()], build_by_default: true) diff --git a/js/ui/background.js b/js/ui/background.js index 8701941..c055fcf 100644 --- a/js/ui/background.js +++ b/js/ui/background.js @@ -533,7 +533,11 @@ var SystemBackground = GObject.registerClass({ let backgroundColor = DEFAULT_BACKGROUND_COLOR; if (imports.misc.desktop.is("ubuntu")) { + const loginSettings = new Gio.Settings({ schema_id: 'com.ubuntu.login-screen' }); + const bgColor = loginSettings.get_string('background-color'); const dummyBgActor = new imports.gi.St.Widget({ name: 'lockDialogGroup' }); + if (bgColor) + dummyBgActor.set_style(`background-color: ${bgColor};`); Main.uiGroup.add_actor(dummyBgActor); backgroundColor = dummyBgActor.get_theme_node().get_background_color(); dummyBgActor.destroy(); diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index 1cc5cb7..7a6867f 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -29,6 +29,12 @@ const DISABLE_LOCK_KEY = 'disable-lock-screen'; const LOCKED_STATE_STR = 'screenShield.locked'; +const LOGIN_SCREEN_SCHEMA = 'com.ubuntu.login-screen'; +const LOGIN_SCREEN_BACKGROUND_COLOR_KEY = 'background-color'; +const LOGIN_SCREEN_BACKGROUND_PICTURE_URI_KEY = 'background-picture-uri'; +const LOGIN_SCREEN_BACKGROUND_REPEAT_KEY = 'background-repeat'; +const LOGIN_SCREEN_BACKGROUND_SIZE_KEY = 'background-size'; + // ScreenShield animation time // - STANDARD_FADE_TIME is used when the session goes idle // - MANUAL_FADE_TIME is used for lowering the shield when asked by the user, @@ -116,6 +122,16 @@ var ScreenShield = class extends Signals.EventEmitter { this._lockSettings = new Gio.Settings({ schema_id: LOCKDOWN_SCHEMA }); this._lockSettings.connect(`changed::${DISABLE_LOCK_KEY}`, this._syncInhibitor.bind(this)); + this._loginScreenSettings = new Gio.Settings({ schema_id: LOGIN_SCREEN_SCHEMA }); + [ + LOGIN_SCREEN_BACKGROUND_COLOR_KEY, + LOGIN_SCREEN_BACKGROUND_PICTURE_URI_KEY, + LOGIN_SCREEN_BACKGROUND_REPEAT_KEY, + LOGIN_SCREEN_BACKGROUND_SIZE_KEY, + ].forEach(schema => this._loginScreenSettings.connect(`changed::${schema}`, + () => this._refreshBackground())); + this._refreshBackground(); + this._isModal = false; this._isGreeter = false; this._isActive = false; @@ -216,6 +232,27 @@ var ScreenShield = class extends Signals.EventEmitter { return this._isModal; } + _refreshBackground() { + const inlineStyle = []; + + const getSetting = s => this._loginScreenSettings.get_string(s); + const backgroundColor = getSetting(LOGIN_SCREEN_BACKGROUND_COLOR_KEY); + const backgroundPictureUri = getSetting(LOGIN_SCREEN_BACKGROUND_PICTURE_URI_KEY); + const backgroundRepeat = getSetting(LOGIN_SCREEN_BACKGROUND_REPEAT_KEY); + const backgroundSize = getSetting(LOGIN_SCREEN_BACKGROUND_SIZE_KEY); + + if (backgroundColor) + inlineStyle.push(`background-color: ${backgroundColor}`); + if (backgroundPictureUri) + inlineStyle.push(`background-image: url("${backgroundPictureUri}")`); + if (backgroundRepeat !== 'default') + inlineStyle.push(`background-repeat: ${backgroundRepeat}`); + if (backgroundSize !== 'default') + inlineStyle.push(`background-size: ${backgroundSize}`); + + this._lockDialogGroup.set_style(inlineStyle.join('; ')); + } + async _syncInhibitor() { const lockEnabled = this._settings.get_boolean(LOCK_ENABLED_KEY) || this._settings.get_boolean(SUSPEND_LOCK_ENABLED_KEY);