mutter/patches/ubuntu/configure_login_screen.patch
Ward Nakchbandi (Cosmic Fusion) deaf92469b
2023-10-03 21:58:03 +03:00

212 lines
9.0 KiB
Diff

From: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
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 | 42 +++++++++++++++++
4 files changed, 123 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+ <enum id="com.ubuntu.login-screen.BackgroundRepeat">
+ <value value="1" nick="default"/>
+ <value value="2" nick="repeat"/>
+ <value value="3" nick="repeat-x"/>
+ <value value="4" nick="repeat-y"/>
+ <value value="5" nick="no-repeat"/>
+ <value value="6" nick="space"/>
+ <value value="7" nick="round"/>
+ </enum>
+ <enum id="com.ubuntu.login-screen.BackgroundSize">
+ <value value="1" nick="default"/>
+ <value value="2" nick="auto"/>
+ <value value="3" nick="cover"/>
+ <value value="4" nick="contain"/>
+ </enum>
+ <schema id="com.ubuntu.login-screen" path="/com/ubuntu/login-screen/">
+ <key name="background-picture-uri" type="s">
+ <default>''</default>
+ <summary>
+ Sets the background image for the login screen.
+ </summary>
+ <description>
+ 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.
+ </description>
+ </key>
+ <key name="background-color" type="s">
+ <default>''</default>
+ <summary>
+ The background-color property sets the background color.
+ </summary>
+ <description>
+ 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.
+ </description>
+ </key>
+ <key name="background-repeat" enum="com.ubuntu.login-screen.BackgroundRepeat">
+ <default>'default'</default>
+ <summary>
+ The background-repeat property sets if/how the background image will be repeated.
+ </summary>
+ <description>
+ 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.
+ </description>
+ </key>
+ <key name="background-size" enum="com.ubuntu.login-screen.BackgroundSize">
+ <default>'default'</default>
+ <summary>
+ The background-size property specifies the size of the background image.
+ </summary>
+ <description>
+ 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.
+ </description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/data/meson.build b/data/meson.build
index a31efcc..07d6d4a 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -97,6 +97,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)
if have_systemd
@@ -125,7 +131,7 @@ endif
# for unit tests - gnome.compile_schemas() only looks in srcdir
custom_target('compile-schemas',
- input: schema,
+ input: [schema, schema_ubuntu_login],
output: 'gschemas.compiled',
command: [find_program('glib-compile-schemas'), data_builddir],
build_by_default: true)
diff --git a/js/ui/background.js b/js/ui/background.js
index cef7c87..0da99da 100644
--- a/js/ui/background.js
+++ b/js/ui/background.js
@@ -543,7 +543,11 @@ export const SystemBackground = GObject.registerClass({
let backgroundColor = DEFAULT_BACKGROUND_COLOR;
if (Desktop.is('ubuntu')) {
+ const loginSettings = new Gio.Settings({schema_id: 'com.ubuntu.login-screen'});
+ const bgColor = loginSettings.get_string('background-color');
const dummyBgActor = new 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 993e436..c27f44b 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -33,6 +33,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 @@ export class ScreenShield 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,31 @@ export class ScreenShield 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 && !backgroundColor.includes('rgba'))
+ 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}`);
+
+ const lockDialogGroupStyle = inlineStyle.join('; ') || null;
+ this._lockDialogGroup.set_style(lockDialogGroupStyle);
+ this._dialog?.set_style(lockDialogGroupStyle ? `
+ background-image: none;
+ background-color: transparent;` : null);
+ }
+
async _syncInhibitor() {
const lockEnabled = this._settings.get_boolean(LOCK_ENABLED_KEY) ||
this._settings.get_boolean(SUSPEND_LOCK_ENABLED_KEY);
@@ -433,6 +474,7 @@ export class ScreenShield extends Signals.EventEmitter {
}
this._dialog = new constructor(this._lockDialogGroup);
+ this._refreshBackground();
let time = global.get_current_time();
if (!this._dialog.open(time)) {