Summary: | Empty ~/.gtkrc-2.0 file is created every time I login | ||
---|---|---|---|
Product: | [Applications] systemsettings | Reporter: | Guilherme Silva <oguilherme> |
Component: | kcm_style | Assignee: | Plasma Bugs List <plasma-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | 1xyzqwrq, alexandreprovencio, aliceaccounts, anubhavkini, i, mail, nate, plasma-bugs, psydev.kde, reuben_p, vmarinescu |
Priority: | NOR | ||
Version: | 5.18.0 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
See Also: | https://bugs.kde.org/show_bug.cgi?id=436427 | ||
Latest Commit: | https://invent.kde.org/plasma/kde-gtk-config/commit/85bfea563102e9a149c54ff420c78972387d73f7 | Version Fixed In: | 5.27.2 |
Sentry Crash Report: | |||
Attachments: |
Patch for kde-gtk-config 5.18.5
Patch for kde-gtk-config 5.19.80 |
Description
Guilherme Silva
2020-02-13 03:17:03 UTC
Probably related to this? https://phabricator.kde.org/D26261 I skimmed through the code a bit and noticed the GTK2 config path is hardcoded to ~/.gtkrc-2.0, plus there's no mention of GTK2_RC_FILES. GTK daemon does not create empty .gtkrc-2.0 and respect GTK2_RC_FILES env variable. Something other is creating it. Could you still reproduce? Dear Bug Submitter, This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed. Thank you for helping us make KDE software even better for everyone! can repro on 5.18.5 Sorry I took this long to respond. Yes, I can still reproduce this on Plasma 5.18.5. A quick search for ".gtkrc-2.0" on KDE's org on Github showed me this file (specifically, the writeGtk2Settings() method): https://github.com/KDE/plasma-workspace/blob/7f2ae10539f2167663aab713986e3f5e0528289f/gmenu-dbusmenu-proxy/menuproxy.cpp#L169 That method doesn't address the GTK2_RC_FILES variable, instead it hardcodes it to ~/.gtkrc-2.0. A bit down in the code, that method is called by writeGtk2Settings(), which I guess ends up creating a new (but empty) .gtkrc-2.0 in my home directory. Just a wild guess, though. I'm not a C++ programmer but I'll try fixing it locally, and I'll let you guys know if that's what's causing the problem. Thanks. Created attachment 129153 [details]
Patch for kde-gtk-config 5.18.5
Actually, never mind my last e-mail. The real culprit is the kde-gtk-config daemon.
Once I:
- Disable its service ("Plasma GTKd") in Plasma's Background Services manager
- Remove the empty ~/.gtkrc-2.0 file
- And, finally, re-login, the file isn't created anymore.
So, brand new steps to reproduce:
1. Open the Background Services manager:
$ kcmshell5 kcmkded
2. Search and disable "Plasma GTKd", hit OK.
3. Make sure there's no .gtkrc-2.0 file in your home folder.
4. Open the Background Services again, but now with GTK2_RC_FILES set:
$ env GTK2_RC_FILES=/tmp/gtkrc kcmshell5 kcmkded
5. Re-enable the "Plasma GTKd" service, hit Apply.
6. There should be an empty .gtkrc-2.0 in your home now:
$ file ~/.gtkrc-2.0
/home/gui/.gtkrc-2.0: empty
I've fixed it locally (without any heavy testing, however) by removing some duplicated code and creating a method that will either respect GTK2_RC_FILES or fallback to ~/.gtkrc-2.0, if GTK2_RC_FILES isn't set or if it's empty.
I'm attaching two patches (they accomplish the same): The first one I made for kde-gtk-config v5.18.5 (the latest version on Arch), and the other one which I just rebased against commit 380bff1f (v5.19.80).
KDE Devs: Feel free to use it (or not), modify it, whatever. I'm reluctant to submit it for review, because I _really_ don't program in C++. So if did that and you guys' asked for modifications, I'd be wasting your time.
If the patch is ready to merge, awesome! If it's not, then I'm sorry.
And thank you for making Plasma so awesome. :)
Created attachment 129154 [details]
Patch for kde-gtk-config 5.19.80
BUMP. Any progress on merging/extending @Guilherme Silva's patch?
I also have this issue.
Logs from .xsession-errors:
> kdeinit5: Got SETENV 'GTK_RC_FILES=/etc/gtk/gtkrc:/home/vlad/.gtkrc:/home/vlad/.config/gtk-1.0/gtkrc:/home/vlad/.config/gtkrc' from launcher.
> kdeinit5: Got SETENV 'GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/vlad/.gtkrc-2.0:/home/vlad/.config/gtk-2.0/gtkrc:/home/vlad/.config/gtkrc-2.0' from launcher.
However, only gtkrc-2.0 is created.
@Guilherme Silva, I am skeptical to disable GTKd background service. What does it do? Also thank you for the patch.
----
Thank you to all KDE team. I love Plasma!
I'm still getting this on `kde-gtk-config` 5.21.5, Wayland, Archlinux. This bug is the only thing that keeps Plasma from being XDG-dirs compliant. I think I've found the cause of this bug, see https://bugs.kde.org/show_bug.cgi?id=415770#c8 Git commit af1cc78d96fdbb2ad9adbb27a37423201b9cc8c9 by Fushan Wen, on behalf of Rocket Aaron. Committed on 25/02/2023 at 14:48. Pushed by fusionfuture into branch 'master'. 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("/.gtkrc-2.0")`: https://invent.kde.org/plasma/plasma-workspace/-/blob/v5.27.1/gmenu-dbusmenu-proxy/menuproxy.cpp#L163 but it's not creating the file if it's not present. `kde-gtk-config`'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 &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'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 "modified" 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 415770 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 Git commit 85bfea563102e9a149c54ff420c78972387d73f7 by Fushan Wen, on behalf of Rocket Aaron. Committed on 25/02/2023 at 14:49. Pushed by fusionfuture into branch 'Plasma/5.27'. 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("/.gtkrc-2.0")`: https://invent.kde.org/plasma/plasma-workspace/-/blob/v5.27.1/gmenu-dbusmenu-proxy/menuproxy.cpp#L163 but it's not creating the file if it's not present. `kde-gtk-config`'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 &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'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 "modified" 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 415770 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 |