<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>415770</bug_id>
          
          <creation_ts>2020-01-01 17:38:18 +0000</creation_ts>
          <short_desc>Environment variable &apos;GTK2_RC_FILES&apos; is ignored</short_desc>
          <delta_ts>2023-02-25 14:51:00 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>systemsettings</product>
          <component>kcm_gtk</component>
          <version>5.17.4</version>
          <rep_platform>Arch Linux</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Guilherme Silva">oguilherme</reporter>
          <assigned_to name="Aleix Pol">aleixpol</assigned_to>
          <cc>b2.temp</cc>
    
    <cc>hentaiwushuang</cc>
    
    <cc>hosxy</cc>
    
    <cc>i</cc>
    
    <cc>mail</cc>
    
    <cc>nate</cc>
    
    <cc>tdhj744ra03u</cc>
          
          <cf_commitlink>https://invent.kde.org/plasma/kde-gtk-config/commit/85bfea563102e9a149c54ff420c78972387d73f7</cf_commitlink>
          <cf_versionfixedin>5.27.2</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1899726</commentid>
    <comment_count>0</comment_count>
    <who name="Guilherme Silva">oguilherme</who>
    <bug_when>2020-01-01 17:38:18 +0000</bug_when>
    <thetext>SUMMARY
The kcm_gtk system component currently ignores the GTK2_RC_FILES environment variable and hardcodes reading/writing to ~/.gtkrc-2.0. I personally have the GTK2_RC_FILES variable set to $XDG_CONFIG_HOME/gtk-2.0/gtkrc in order to avoid cluttering my home directory.

STEPS TO REPRODUCE
1. Open the terminal.
2. Backup your current ~/.gtkrc-2.0: (Don&apos;t forget to restore it afterwards! :)
&gt; mv ~/.gtkrc-2.0 ~/.gtkrc-2.0.bak
3. Point GTK2_RC_FILES to your backup file:
&gt; export GTK2_RC_FILES=~/.gtkrc-2.0.bak
4. Launch Plasma&apos;s GTK config.:
&gt; kcmshell5 kde-gtk-config

OBSERVED RESULT
kde-gtk-config still tries to read from ~/.gtkrc-2.0 instead of ~/.gtkrc-2.0.bak.

EXPECTED RESULT
kde-gtk-config should respect the GTK2_RC_FILES variable when reading/writing to the GTK2 config file.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 5.17.4
KDE Frameworks Version: 5.65.0
Qt Version: 5.14.0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1900108</commentid>
    <comment_count>1</comment_count>
    <who name="Mikhail Zolotukhin">mail</who>
    <bug_when>2020-01-02 20:30:09 +0000</bug_when>
    <thetext>Git commit 5734413d8105699252a3a0cfbba2265169581909 by Mikhail Zolotukhin.
Committed on 02/01/2020 at 20:29.
Pushed by gikari into branch &apos;master&apos;.

Respect GTK2_RC_FILES environmental variable

Summary:
If the above variable is set and it does not contain multiple paths,
write GTK2 config into the designated config file, instead of the
default one.
FIXED-IN: 5.18.0

Test Plan:
Check if the custom file provided by env variable is modified, when changing any settings, that are synchronized by kded module (icon theme, cursor theme etc)
Simple test:

# `mv ~/.gtkrc-2.0 ~/.gtkrc-2.0.bak`
# `export GTK2_RC_FILES=~/.gtkrc-2.0.bak`
# Restart kded5 with the above env variable
# Change e.g. icon theme and see, that `.gtkrc-2.0.bak` is modified, but `.gtkrc-2.0`

Reviewers: ngraham

Reviewed By: ngraham

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26375

M  +4    -1    kded/configeditor.cpp

https://commits.kde.org/kde-gtk-config/5734413d8105699252a3a0cfbba2265169581909</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1900112</commentid>
    <comment_count>2</comment_count>
    <who name="Guilherme Silva">oguilherme</who>
    <bug_when>2020-01-02 20:37:36 +0000</bug_when>
    <thetext>That was fast! Thanks a bunch, guys! 🎉</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1907735</commentid>
    <comment_count>3</comment_count>
    <who name="Mikhail Zolotukhin">mail</who>
    <bug_when>2020-02-05 18:34:25 +0000</bug_when>
    <thetext>*** Bug 417090 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2179534</commentid>
    <comment_count>4</comment_count>
    <who name="daiaji">hentaiwushuang</who>
    <bug_when>2022-11-30 16:16:38 +0000</bug_when>
    <thetext>Even if I declare the GTK2_RC_FILES variable, ~/.gtkrc-2.0 is still created, I don&apos;t know what&apos;s going on.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2179560</commentid>
    <comment_count>5</comment_count>
    <who name="daiaji">hentaiwushuang</who>
    <bug_when>2022-11-30 17:23:21 +0000</bug_when>
    <thetext>```
2022-12-01 01:16:18,148 INFO [default] Configuration file : /home/test/loggedfs.xml
2022-12-01 01:16:18,148 INFO [default] LoggedFS starting at /home/test.
2022-12-01 01:16:18,148 INFO [default] Using configuration file /home/test/loggedfs.xml.
2022-12-01 01:16:18,149 INFO [default] chdir to /home/test
2022-12-01 01:16:27,108 INFO [default] mknod /home/test/.gtkrc-2.0 100644 S_IFREG (normal file creation) {SUCCESS} [ pid = 4916 /usr/bin/kded5 uid = 1000 ]
2022-12-01 01:16:27,108 INFO [default] open readwrite /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 4916 /usr/bin/kded5 uid = 1000 ]
2022-12-01 01:16:27,108 INFO [default] release /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 0 (null) uid = 0 ]
2022-12-01 01:16:27,108 INFO [default] unlink /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 4916 /usr/bin/kded5 uid = 1000 ]
2022-12-01 01:16:27,108 INFO [default] mknod /home/test/.gtkrc-2.0 100644 S_IFREG (normal file creation) {SUCCESS} [ pid = 4916 /usr/bin/kded5 uid = 1000 ]
2022-12-01 01:16:27,109 INFO [default] open writeonly /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 4916 /usr/bin/kded5 uid = 1000 ]
2022-12-01 01:16:27,109 INFO [default] release /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 0 (null) uid = 0 ]
2022-12-01 01:16:27,405 INFO [default] open readwrite /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 5116 /usr/bin/gmenudbusmenuproxy uid = 1000 ]
2022-12-01 01:16:27,405 INFO [default] truncate /home/test/.gtkrc-2.0 to 0 bytes {SUCCESS} [ pid = 5116 /usr/bin/gmenudbusmenuproxy uid = 1000 ]
2022-12-01 01:16:27,405 INFO [default] release /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 0 (null) uid = 0 ]
2022-12-01 01:16:27,409 INFO [default] statfs /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 5116 /usr/bin/gmenudbusmenuproxy uid = 1000 ]
2022-12-01 01:16:32,388 INFO [default] open /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 5637 /usr/bin/dolphin uid = 1000 ]
2022-12-01 01:16:32,388 INFO [default] release /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 0 (null) uid = 0 ]
2022-12-01 01:16:32,396 INFO [default] statfs /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 5637 /usr/bin/dolphin uid = 1000 ]
2022-12-01 01:17:01,049 INFO [default] open readwrite /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 5116 /usr/bin/gmenudbusmenuproxy uid = 1000 ]
2022-12-01 01:17:01,049 INFO [default] truncate /home/test/.gtkrc-2.0 to 0 bytes {SUCCESS} [ pid = 5116 /usr/bin/gmenudbusmenuproxy uid = 1000 ]
2022-12-01 01:17:01,049 INFO [default] release /home/test/.gtkrc-2.0 {SUCCESS} [ pid = 0 (null) uid = 0 ]
2022-12-01 01:17:01,542 INFO [default] LoggedFS closing.
```
```
cat /etc/security/pam_env.conf

XDG_CONFIG_HOME DEFAULT=@{HOME}/.config
XDG_CACHE_HOME DEFAULT=@{HOME}/.cache
XDG_DATA_HOME DEFAULT=@{HOME}/.local/share
XDG_STATE_HOME DEFAULT=@{HOME}/.local/state

GTK2_RC_FILES DEFAULT=${XDG_CONFIG_HOME}/gtk-2.0/gtkrc
```
Return of the bug?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2206583</commentid>
    <comment_count>6</comment_count>
    <who name="Andrei">tdhj744ra03u</who>
    <bug_when>2023-02-10 01:32:33 +0000</bug_when>
    <thetext>Same issue:
Operating System: Kubuntu 22.10
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2206789</commentid>
    <comment_count>7</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2023-02-11 02:34:53 +0000</bug_when>
    <thetext>This was fixed ages ago with no other reports since then. I suspect the issue you&apos;re facing is either something else or at least has a different root cause. Please file a new (detailed) bug report for it. In general it&apos;s best to file a new report rather than re-opening an old one. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2209574</commentid>
    <comment_count>8</comment_count>
    <who name="Rocket Aaron">i</who>
    <bug_when>2023-02-19 09:30:38 +0000</bug_when>
    <thetext>I can reproduce it too, on Plasma 5.27.0. After some experiment, I think I&apos;ve figured out what&apos;s happening.

gmenu-dbusmenu-proxy hardcoded gtkrcPath as `QDir::homePath() + QLatin1String(&quot;/.gtkrc-2.0&quot;)`, but it&apos;s not creating the file if it&apos;s not present. kde-gtk-config&apos;s `Gtk2ConfigEditor::removeLegacyStrings()` is the cause:
https://github.com/KDE/kde-gtk-config/blob/4a9185dbc67543544f7010cf39e6c87af44aeca8/kded/config_editor/gtk2.cpp#L54
it uses `Utils::readFileContents(QFile &amp;file)`
https://github.com/KDE/kde-gtk-config/blob/4a9185dbc67543544f7010cf39e6c87af44aeca8/kded/config_editor/utils.cpp#L19
which calls `file.open(QIODevice::ReadWrite | QIODevice::Text)`
and the mode `ReadWrite` means to create the file if it&apos;s not exist:
https://doc.qt.io/qt-5/qfile.html#open

So at startup, kde-gtk-config launches and a empty `~/.gtkrc-2.0` file is created, then gmenu-dbusmenu-proxy watchs the file creation
https://github.com/KDE/plasma-workspace/blob/89d1f0e07955427a083cbc5af34e0ae9fdcdaad4/gmenu-dbusmenu-proxy/menuproxy.cpp#L106
and write the content to the file.

If gmenu-dbusmenu-proxy is disabled, it would simply results an empty `~/.gtkrc-2.0` file, as this bug describes:
https://bugs.kde.org/show_bug.cgi?id=417534</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2211653</commentid>
    <comment_count>9</comment_count>
    <who name="Fushan Wen">qydwhotmail</who>
    <bug_when>2023-02-25 14:48:47 +0000</bug_when>
    <thetext>Git commit af1cc78d96fdbb2ad9adbb27a37423201b9cc8c9 by Fushan Wen, on behalf of Rocket Aaron.
Committed on 25/02/2023 at 14:48.
Pushed by fusionfuture into branch &apos;master&apos;.

Avoid creating gtkrc-2.0 if it does not exist

This MR would fix the following 2 bugs: Plasma does not follow `GTK2_RC_FILES` environment variable and would create `~/.gtkrc-2.0` every time on login.

---

Here is the more detailed explanation:

`gmenu-dbusmenu-proxy` hardcoded `gtkrcPath` as `QDir::homePath() + QLatin1String(&quot;/.gtkrc-2.0&quot;)`:

https://invent.kde.org/plasma/plasma-workspace/-/blob/v5.27.1/gmenu-dbusmenu-proxy/menuproxy.cpp#L163

but it&apos;s not creating the file if it&apos;s not present. `kde-gtk-config`&apos;s `Gtk2ConfigEditor::removeLegacyStrings()` is the cause:

https://invent.kde.org/plasma/kde-gtk-config/-/blob/v5.27.1/kded/config_editor/gtk2.cpp#L54

it uses `Utils::readFileContents(QFile &amp;file)`

https://invent.kde.org/plasma/kde-gtk-config/-/blob/v5.27.1/kded/config_editor/utils.cpp#L19

which calls `file.open(QIODevice::ReadWrite | QIODevice::Text)`, and the mode `ReadWrite` means to create the file if it&apos;s not exist:

https://doc.qt.io/qt-5/qfile.html#open

So at startup, `kde-gtk-config` launches and a empty `~/.gtkrc-2.0` file is created, then `gmenu-dbusmenu-proxy` watchs the file creation

https://invent.kde.org/plasma/plasma-workspace/-/blob/v5.27.1/gmenu-dbusmenu-proxy/menuproxy.cpp#L106

and write the content to the file.

Furthermore, even if `~/.gtkrc-2.0` does not exist, `Gtk2ConfigEditor::removeLegacyStrings()` would still write &quot;modified&quot; content to the file

https://invent.kde.org/plasma/kde-gtk-config/-/blob/v5.27.1/kded/config_editor/gtk2.cpp#L76

but in that case, it would just create an empty file, for `gmenu-dbusmenu-proxy` to watch and write something to it.
Related: bug 417534
FIXED-IN: 5.27.2

M  +3    -0    kded/config_editor/gtk2.cpp
M  +1    -1    kded/config_editor/utils.cpp

https://invent.kde.org/plasma/kde-gtk-config/commit/af1cc78d96fdbb2ad9adbb27a37423201b9cc8c9</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2211656</commentid>
    <comment_count>10</comment_count>
    <who name="Fushan Wen">qydwhotmail</who>
    <bug_when>2023-02-25 14:51:00 +0000</bug_when>
    <thetext>Git commit 85bfea563102e9a149c54ff420c78972387d73f7 by Fushan Wen, on behalf of Rocket Aaron.
Committed on 25/02/2023 at 14:49.
Pushed by fusionfuture into branch &apos;Plasma/5.27&apos;.

Avoid creating gtkrc-2.0 if it does not exist

This MR would fix the following 2 bugs: Plasma does not follow `GTK2_RC_FILES` environment variable and would create `~/.gtkrc-2.0` every time on login.

---

Here is the more detailed explanation:

`gmenu-dbusmenu-proxy` hardcoded `gtkrcPath` as `QDir::homePath() + QLatin1String(&quot;/.gtkrc-2.0&quot;)`:

https://invent.kde.org/plasma/plasma-workspace/-/blob/v5.27.1/gmenu-dbusmenu-proxy/menuproxy.cpp#L163

but it&apos;s not creating the file if it&apos;s not present. `kde-gtk-config`&apos;s `Gtk2ConfigEditor::removeLegacyStrings()` is the cause:

https://invent.kde.org/plasma/kde-gtk-config/-/blob/v5.27.1/kded/config_editor/gtk2.cpp#L54

it uses `Utils::readFileContents(QFile &amp;file)`

https://invent.kde.org/plasma/kde-gtk-config/-/blob/v5.27.1/kded/config_editor/utils.cpp#L19

which calls `file.open(QIODevice::ReadWrite | QIODevice::Text)`, and the mode `ReadWrite` means to create the file if it&apos;s not exist:

https://doc.qt.io/qt-5/qfile.html#open

So at startup, `kde-gtk-config` launches and a empty `~/.gtkrc-2.0` file is created, then `gmenu-dbusmenu-proxy` watchs the file creation

https://invent.kde.org/plasma/plasma-workspace/-/blob/v5.27.1/gmenu-dbusmenu-proxy/menuproxy.cpp#L106

and write the content to the file.

Furthermore, even if `~/.gtkrc-2.0` does not exist, `Gtk2ConfigEditor::removeLegacyStrings()` would still write &quot;modified&quot; content to the file

https://invent.kde.org/plasma/kde-gtk-config/-/blob/v5.27.1/kded/config_editor/gtk2.cpp#L76

but in that case, it would just create an empty file, for `gmenu-dbusmenu-proxy` to watch and write something to it.
Related: bug 417534
FIXED-IN: 5.27.2


(cherry picked from commit af1cc78d96fdbb2ad9adbb27a37423201b9cc8c9)

M  +3    -0    kded/config_editor/gtk2.cpp
M  +1    -1    kded/config_editor/utils.cpp

https://invent.kde.org/plasma/kde-gtk-config/commit/85bfea563102e9a149c54ff420c78972387d73f7</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>