From fb2cd90e2e3b9be890810da7837037af68f2f784 Mon Sep 17 00:00:00 2001 From: Ross Brunton Date: Thu, 26 Sep 2024 19:46:23 +0100 Subject: [PATCH] Respect `$GTK2_RC_FILES` when writing themes `GTK2_RC_FILES` is an environment variable containing a colon seperated list of RC files that are used to theme GTK2 applications. This patch will write GTK2 theming to the first file in this list, if present, rather than ~/.gtkrc-2.0. --- .../cinnamon-settings/bin/CinnamonGtkSettings.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/CinnamonGtkSettings.py b/files/usr/share/cinnamon/cinnamon-settings/bin/CinnamonGtkSettings.py index cf2a75aea5..82d0a8b039 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/CinnamonGtkSettings.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/CinnamonGtkSettings.py @@ -408,7 +408,11 @@ def on_overlay_scrollbars_changed(self, settings, key, data=None): class Gtk2ScrollbarSizeEditor: def __init__(self, ui_scale): - self._path = os.path.join(GLib.get_home_dir(), ".gtkrc-2.0") + rcpath = GLib.getenv("GTK2_RC_FILES") + if rcpath is None or rcpath == "": + self._path = os.path.join(GLib.get_home_dir(), ".gtkrc-2.0") + else: + self._path = rcpath.split(":")[0] self._file = Gio.File.new_for_path(self._path) self._settings = Gio.Settings(schema_id="org.cinnamon.theme") self.ui_scale = ui_scale @@ -425,7 +429,7 @@ def __init__(self, ui_scale): if e.code == Gio.IOErrorEnum.NOT_FOUND: pass else: - print("Could not load ~/.gtkrc-2.0 file: %s" % e.message) + print("Could not load .gtkrc-2.0 file: %s" % e.message) self.parse_contents() @@ -450,6 +454,9 @@ def on_set_size_timeout(self, size): # print("saving changed: ", final_contents) try: + # If a path is specified through GTK2_RC_FILES, ensure it exists + if not self._file.get_parent().query_exists(): + self._file.get_parent().make_directory_with_parents() self._file.replace_contents(final_contents.encode("utf-8"), None, False,