From: Didier Roche Date: Tue, 22 Oct 2019 11:22:06 +0200 Subject: Resolve real path name for theme file We are using alternative theme paths. Some of them are symlinks like gdm3.css. It points to a different directory and we need to ensure assets are loaded from the real theme path then (assets path are relative to it). Resolve them symlinks to ensure we use the original file itself when loading the stylesheet. Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/1798747 Forwarded: Not-needed (upstream doesn't support officially theming) --- js/ui/main.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/ui/main.js b/js/ui/main.js index b3fff22..8c0664a 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -385,6 +385,14 @@ async function _handleLockScreenWarning() { } } +function _realpath(path) { + try { + while (GLib.file_test(path, GLib.FileTest.IS_SYMLINK)) + path = GLib.file_read_link(path); + } catch (e) { } + return path; +} + function _getStylesheet(name) { let stylesheet; @@ -395,12 +403,12 @@ function _getStylesheet(name) { let dataDirs = GLib.get_system_data_dirs(); for (let i = 0; i < dataDirs.length; i++) { let path = GLib.build_filenamev([dataDirs[i], 'gnome-shell', 'theme', name]); - stylesheet = Gio.file_new_for_path(path); + stylesheet = Gio.file_new_for_path(_realpath(path)); if (stylesheet.query_exists(null)) return stylesheet; } - stylesheet = Gio.File.new_for_path(`${global.datadir}/theme/${name}`); + stylesheet = Gio.File.new_for_path(_realpath(`${global.datadir}/theme/${name}`)); if (stylesheet.query_exists(null)) return stylesheet;