Bug 1754395 - Qt applications lose system theme if launched via dbus activation (from flatpak applications or krunner)
Summary: Qt applications lose system theme if launched via dbus activation (from flatp...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: plasma-workspace
Version: 31
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: KDE SIG
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1749362 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-09-23 07:17 UTC by P D
Modified: 2020-04-23 14:57 UTC (History)
15 users (show)

Fixed In Version: dolphin-19.08.2-2.fc31
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-10-31 00:57:17 UTC
Type: Bug


Attachments (Terms of Use)
dolphin-ugly (72.36 KB, image/png)
2019-09-23 07:17 UTC, P D
no flags Details
what dolphin is supposed to look like (85.00 KB, image/png)
2019-09-23 07:17 UTC, P D
no flags Details
plasma-workspace-5.18.4.1-filter-environment.patch (1.26 KB, patch)
2020-04-03 12:20 UTC, Yaroslav Sidlovsky
no flags Details | Diff
plasma-workspace-5.18.4.1-filter-environment-v2.patch (1.63 KB, patch)
2020-04-03 17:53 UTC, Yaroslav Sidlovsky
no flags Details | Diff
plasma-workspace-5.18.4.1-filter-environment-v2.patch (1.63 KB, patch)
2020-04-03 18:09 UTC, Yaroslav Sidlovsky
no flags Details | Diff

Description P D 2019-09-23 07:17:05 UTC
Created attachment 1618064 [details]
dolphin-ugly

Description of problem:

Note: I couldn't find which component to file this bug under so I picked dolphin because this bug affects dolphin (as well as other qt applications)

When launching a KDE / QT application such as Dolphin or Spectacle from an application that utilizes qdbus, the qt application will lose the user selected widget style (usually breeze) and use the ugly default qt theme. For example, in the dropbox flatpak from flathub, if I open dropbox folder from the tray icon, dolphin launches without theming and looks ugly. Or if I enabled the file / folder search in krunner, and open a folder that exists on my system in dolphin with krunner, it loses the theme. If I launch Dolphin (only the application, just launching from the .desktop file) in krunner the theme works. This issue can be quickly reproduced by launching Spectacle in the terminal normally (theme works), then launching it with this command: 

qdbus org.kde.Spectacle / StartAgent

in which spectacle launches without the theme (ugly)

Version-Release number of selected component (if applicable):

not sure what component provides qdbus

How reproducible:

Very.

Steps to Reproduce:
1. launch spectacle in terminal normally (theme works)
2. close spectacle
3. launch spectacle with this command: qdbus org.kde.Spectacle / StartAgent
4. notice theme looks ugly

Actual results:

When launching a qt application from qdbus or from flatpak it loses the theme.

Expected results:

The theme should work when launching qt applications in this way.

Additional info:

Attached is an screenshot of what Dolphin looks like on my system when launching from dropbox flatpak or selecting a folder in krunner. (dolphin-ugly.png)

Also attached is what dolphin looks like when launching normally. (dolphin-normal.png)

Comment 1 P D 2019-09-23 07:17:54 UTC
Created attachment 1618065 [details]
what dolphin is supposed to look like

Comment 2 P D 2019-10-17 12:57:32 UTC
Does anyone pay attention to these bug reports?

Comment 3 Rex Dieter 2019-10-17 16:38:39 UTC
Yes, people pay attention.  Personally, I've just had no time to look deeply yet, even less so to add acknowledgements for every incoming bug report.  Patience grasshopper.

That said, this almost certainly isn't a dolphin issue (ie, problem lies elsewhere).  One possibility:  dbus-activated applications may not inherit (all? any?) user environment variables

Comment 4 Fedora Update System 2019-10-18 16:16:08 UTC
FEDORA-2019-1f174ad525 has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-1f174ad525

Comment 5 Fedora Update System 2019-10-18 17:36:14 UTC
baloo-widgets-19.08.2-1.fc31, dolphin-19.08.2-2.fc31, dolphin-plugins-19.08.2-1.fc31, kate-19.08.2-1.fc31, kdialog-19.08.2-1.fc31, keditbookmarks-19.08.2-1.fc31, kfind-19.08.2-1.fc31, khelpcenter-19.08.2-1.fc31, konqueror-19.08.2-1.fc31, konsole5-19.08.2-1.fc31, yakuake-19.08.2-1.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-1f174ad525

Comment 6 P D 2019-10-19 01:12:24 UTC
Hi, thanks for taking a look at this. However, even with that dolphin update, the issue still occurs with dolphin. (And other qt applications, but that would require some other update)

Comment 7 Fedora Update System 2019-10-31 00:57:17 UTC
baloo-widgets-19.08.2-1.fc31, dolphin-19.08.2-2.fc31, dolphin-plugins-19.08.2-1.fc31, kate-19.08.2-1.fc31, kdialog-19.08.2-1.fc31, keditbookmarks-19.08.2-1.fc31, kfind-19.08.2-1.fc31, khelpcenter-19.08.2-1.fc31, konqueror-19.08.2-1.fc31, konsole5-19.08.2-1.fc31, yakuake-19.08.2-1.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.

Comment 8 P D 2019-10-31 03:29:58 UTC
This is not fixed.

Comment 9 Nick Cross 2019-11-11 07:39:00 UTC
Related bug 1749362 ?

Comment 10 P D 2019-11-11 07:43:09 UTC
Yes. Same bug.

Comment 11 Rex Dieter 2019-11-12 14:48:32 UTC
The update above should fix dolphin, as it is no longer dbus-activated on f31+ (it is autostarted with: dolphin --daemon on session start instead).

Comment 12 Rex Dieter 2019-11-12 14:50:34 UTC
*** Bug 1749362 has been marked as a duplicate of this bug. ***

Comment 13 P D 2019-11-12 15:37:00 UTC
It doesn't fix it, as dolphin can still be launched with dbus (for example - from a flatpak)

Comment 14 Rex Dieter 2019-11-12 20:06:32 UTC
Interesting, the mechanism is different now.

dolphin running as a background daemon listening on that dbus interface (as part of your user session) now launches dolphin, instead of dbus itself.  Means that the dolphin daemon isn't inheriting your session environment properly either?

Odd, I recall it working for me in my own testing at the time I made the update (I don't have a f31 box handy currently to retest).

Comment 15 Sudhir Khanger 2019-11-26 05:33:28 UTC
I am experiencing this with KeePassXC on Fedora 31. When I launch it via terminal it works as expected but when launched from KRunner then the theme gets messed up.

Comment 16 Yaroslav Sidlovsky 2019-11-30 13:44:22 UTC
Don't know if it's related or not but I have following error when running `dbus-update-activation-environment --all --systemd` from the console:

dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.InvalidArgs: Invalid environment assignments

Also I see such errors in the ~/.xsession-errors after every login to KDE.

Comment 17 Yaroslav Sidlovsky 2019-11-30 16:58:42 UTC
Issue is gone after I uninstall package Lmod, it exports some env variables with new lines and tab characters (BASH_FUNC_ml%% and some other).
Command `systemctl --user import-environment` will fail to import those variables.

Comment 18 Vitaly Zaitsev 2019-11-30 17:42:49 UTC
Removal of Lmod package fixed issue for me with Spectacle.

Comment 19 P D 2019-11-30 19:40:03 UTC
Removing Lmod solved the issue for me. I had to do it via "sudo rpm -e --nodeps Lmod" because some packages I use (like Kdenlive) depended on it.

Comment 20 Sudhir Khanger 2019-12-01 06:24:30 UTC
Can Lmod be removed safely without it causing harm to other apps like Kdenlive?

Comment 21 P D 2019-12-01 06:55:06 UTC
I haven't noticed any issues in my minimal testing, and I don't think it's needed though I'm not sure what Lmod does.

Comment 22 Michael 2019-12-03 21:34:17 UTC
I also removed Lmod, and got system themes back in Spectacle. For many users, it seems to be a dependency (in my case, the Nomacs image viewer). It seems that the reason we all have this same bug is OpenCV, which both Nomacs and Kdenlive are using.

I'm a rookie in these parts though, so I'll leave it to The Powers That Be to decide whether a bug should be filed against Lmod instead dolphin.

Comment 23 Nick Cross 2019-12-04 11:03:54 UTC
I am also seeing this and this dependency seems to be required by e.g. digikam.

Comment 24 Eric Mesa 2020-03-02 22:35:35 UTC
Want to add that this is affecting Spectacle for me on KDE Plasma with Fedora 31 updated to the latest packages.

Comment 25 Nan Zou 2020-03-23 19:44:49 UTC
I had this annoying problem also with Spectacle.  Not only losing the system theme but also the 2x scaling which made it impossible to use on my HiDPI screen.

The comment #17 above about importing user environment gave me some tips on solving this issue.

Here are my steps:

run 'systemctl --user import-environment' from the command line.

If you see any errors, then your environment failed to get passed into systemd user instance, and therefore not passed into dbus activated programs. 

The next step would be to pin-point where the error occurs during the import.  For this I'm afraid there's no approach other than trial and error.  Start with the most basic .bashrc, or .zshrc, etc.  Then invoke a login shell (normally with the -l argument to the shell), and rerun the import command above.  You may need to disable the scripts under /etc/profile.d as well.

Comment 26 Eric Mesa 2020-03-26 21:16:43 UTC
If #25 is right - it'd be nice if we could have some confirmation or a script we could run to check this.

Comment 27 Yaroslav Sidlovsky 2020-03-27 09:38:16 UTC
Cause of this bug is simple - systemd don't import ALL enviroment variables if any variable name is not POSIX compilant
(it must conform to the regex [0-9A-Z_], see: https://github.com/systemd/systemd/blob/a859abf062cef1511e4879c4ee39c6036ebeaec8/src/basic/env-util.c#L19).

You can test it with this command: `env %=1 systemctl --user import-environment`, it will fail.

Now there is 2 known packages exporting those variables: environment-modules and Lmod.

Solution is simple - skip ONLY invalid variables while importing others.

I've created bug in the systemd, but still without answer - https://github.com/systemd/systemd/issues/14878.

Comment 28 Yaroslav Sidlovsky 2020-04-03 12:20:35 UTC
Created attachment 1675998 [details]
plasma-workspace-5.18.4.1-filter-environment.patch

If the mountain will not come to Muhammad...

There is a patch to fix this issue for KDE.
It must be applied to the plasma-workspace.
Someone - please test it, it should help, but anyway some testing required.

Comment 29 P D 2020-04-03 12:59:13 UTC
(In reply to Yaroslav Sidlovsky from comment #28)
> Created attachment 1675998 [details]
> plasma-workspace-5.18.4.1-filter-environment.patch
> 
> If the mountain will not come to Muhammad...
> 
> There is a patch to fix this issue for KDE.
> It must be applied to the plasma-workspace.
> Someone - please test it, it should help, but anyway some testing required.

I tested the patch because you uploaded it to your copr repo and it seems to work fine.

Comment 30 Rex Dieter 2020-04-03 17:24:36 UTC
https://src.fedoraproject.org/rpms/plasma-workspace/c/c7021c7de4738619fcc9b61ce27c762ce4dc1f89?branch=master

imported patch, only for f32+ currently.  

Will likely be working on plasma-5.18 update for f31 soon that will include this fix too

Comment 31 Yaroslav Sidlovsky 2020-04-03 17:53:18 UTC
Created attachment 1676095 [details]
plasma-workspace-5.18.4.1-filter-environment-v2.patch

I've just made more complex and more correct (as I think) patch that modifies environment only for process "dbus-update-activation-environment".

After applying this patch:

$ LANG=C journalctl -b 0 -g 'environment variable removed'
-- Logs begin at Fri 2020-04-03 11:15:20 MSK, end at Fri 2020-04-03 20:51:11 MSK. --
Apr 03 20:44:31 rapidus startplasma-x11[170521]: program: "dbus-update-activation-environment" environment variable removed: "BASH_FUNC_ml%%"
Apr 03 20:44:31 rapidus startplasma-x11[170521]: program: "dbus-update-activation-environment" environment variable removed: "BASH_FUNC_module%%"
Apr 03 20:44:31 rapidus startplasma-x11[170521]: program: "dbus-update-activation-environment" environment variable removed: "LMOD_sys"

Comment 32 Yaroslav Sidlovsky 2020-04-03 18:09:39 UTC
Created attachment 1676096 [details]
plasma-workspace-5.18.4.1-filter-environment-v2.patch

Comment 33 Rex Dieter 2020-04-09 15:39:10 UTC
Thanks, triaging to plasma-workspace component

Applied latest patch submission to plasma-workspace :

%changelog
* Thu Apr 09 2020 Rex Dieter <rdieter@fedoraproject.org> - 5.18.4.1-2
- update patch "Qt applications lose system theme if launched via dbus activation" (#1754395)

Comment 34 Eric Mesa 2020-04-23 14:57:03 UTC
As of most recent updates it appears to be fixed now. At least I can launch KDE programs from the launcher and they're coming up with the right theme instead of a light theme.


Note You need to log in before you can comment on or make changes to this bug.