Bug 415770 - Environment variable 'GTK2_RC_FILES' is ignored
Summary: Environment variable 'GTK2_RC_FILES' is ignored
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_gtk (show other bugs)
Version: 5.17.4
Platform: Archlinux Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Aleix Pol
URL:
Keywords:
: 417090 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-01-01 17:38 UTC by Guilherme Silva
Modified: 2022-11-30 17:23 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.18.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guilherme Silva 2020-01-01 17:38:18 UTC
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't forget to restore it afterwards! :)
> mv ~/.gtkrc-2.0 ~/.gtkrc-2.0.bak
3. Point GTK2_RC_FILES to your backup file:
> export GTK2_RC_FILES=~/.gtkrc-2.0.bak
4. Launch Plasma's GTK config.:
> 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
Comment 1 Mikhail Zolotukhin 2020-01-02 20:30:09 UTC
Git commit 5734413d8105699252a3a0cfbba2265169581909 by Mikhail Zolotukhin.
Committed on 02/01/2020 at 20:29.
Pushed by gikari into branch 'master'.

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
Comment 2 Guilherme Silva 2020-01-02 20:37:36 UTC
That was fast! Thanks a bunch, guys! 🎉
Comment 3 Mikhail Zolotukhin 2020-02-05 18:34:25 UTC
*** Bug 417090 has been marked as a duplicate of this bug. ***
Comment 4 daiaji 2022-11-30 16:16:38 UTC
Even if I declare the GTK2_RC_FILES variable, ~/.gtkrc-2.0 is still created, I don't know what's going on.
Comment 5 daiaji 2022-11-30 17:23:21 UTC
```
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?