stylix icon indicating copy to clipboard operation
stylix copied to clipboard

qt: support Flatpak

Open bricked-dev opened this issue 1 year ago • 4 comments

As pointed out in https://github.com/danth/stylix/pull/693#issuecomment-2679632369, QT apps aren't styled when installed as Flatpaks. This article describes how support may be added. I already attempted it but couldn't get it to work.

bricked-dev avatar Feb 25 '25 11:02 bricked-dev

hello so I did a little bit more digging to find some solutions first of all i recommend renaming the symlink home manager to something else other than global and copying the file and renaming the new file to global I used this command a lot strace -f -t -e trace=file flatpak run org.kde.kclock 2> a_file anyway I recommand using it against native qt apps (installed using nixpkgs) and flatpaks anyway I managed to at least remove the invalid error from apps Image even thout its not themed I think thats progress so I might as well share what I found

basically my first step was this

Image basically I putted everything I ran ls -la on inside of the flatpak override file in .local/share/flatpak/overrides/global btw that basically is /nix/store/gm9k1g3b6nw0qavlj9nv9ncwcv55m4ql-kvantum.kvconfig;/nix/store/ihy1yjrfw6sqc3861dsgaj5zbrjvdd9i-base16-kvantum/share/Kvantum/Base16Kvantum;/nix/store/fjnwzr8hmqcczcg3pprzka4n5zsc4kk2-home-manager-files/.config/Kvantum;xdg-config/Kvantum

than using this command echo $QT_PLUGIN_PATH I found paths I though that was interesting so I used find to find any mention of kvantum this is the command i used find -L $(echo $QT_PLUGIN_PATH | awk 'gsub(":"," ")') -regex ".*kvantum.*"

and would you look at that /etc/profiles/per-user/behe/lib/qt-6/plugins/styles/libkvantum.so this is mentioned for exemple I tried opening that path up for flatpak at first but well

Image flatpaks are well yeah thats not very secure so my next approach was just realpath /etc/profiles/per-user/behe/lib/qt-6/plugins realpath /etc/profiles/per-user/behe/lib/qt-5.15.16/plugins I opened up the realpath (which is nix store obv) btw I need to open this as well Image

and now finally I can open the kde app and it will magicly work but no I need to change QT_PLUGIN_PATH for flatpaks since by default its only QT_PLUGIN_PATH=/app/lib/plugins:/usr/share/runtime/lib/plugins easy fix just add whats missing QT_PLUGIN_PATH=/nix/store/vs4ykbnlhy6vwncq99r31pi29q8y7s9y-home-manager-path/lib/qt-6/plugins:/nix/store/vs4ykbnlhy6vwncq99r31pi29q8y7s9y-home-manager-path/lib/qt-5.15.16/plugins:/app/lib/plugins:/usr/share/runtime/lib/plugins and this is where I'm at error is gone but theme not applied even though well I can assure you there are some effects exemples: before:

Image after:

Image

Image

so its a problem in somehow applying the theme somehow using strace I can see that kclock is actually reading kvantum but I don't know how to make qt application more verbose or at least make them use dark theme lol so yeah any ideas

bohanubis avatar Feb 26 '25 19:02 bohanubis

QT_LOGGING_RULES="*=true" I learned about the existence of this environment variable but still nothing useful so far I can see using this QT_LOGGING_RULES="qt.quick.controls.style.debug=true;qt.core.plugin.factoryloader.debug=true" flatpak run org.kde.kclock -style kvantum-dark 2> wow1 that kvantum is getting loaded but the style never changes heres a file of everything (33k lines of logs)

wow1.txt

yeah help will be appreciated

bohanubis avatar Feb 26 '25 21:02 bohanubis

Nice, I was able to reproduce this behaviour!

; .local/share/flatpak/overrides/global
[Context]
filesystems=/nix/store:ro;/home/bricked/.themes/adw-gtk3:ro;/home/bricked:ro;/home/bricked/.config/Kvantum:ro;

[Environment]
GTK_THEME=adw-gtk3
QT_PLUGIN_PATH=/home/bricked/.local/share/flatpak/exports/lib/qt-5.15.16/plugins:/home/bricked/.local/share/flatpak/exports/lib/qt-6/plugins:/var/lib/flatpak/exports/lib/qt-5.15.16/plugins:/var/lib/flatpak/exports/lib/qt-6/plugins:/home/bricked/.nix-profile/lib/qt-5.15.16/plugins:/home/bricked/.nix-profile/lib/qt-6/plugins:/nix/profile/lib/qt-5.15.16/plugins:/nix/profile/lib/qt-6/plugins:/home/bricked/.local/state/nix/profile/lib/qt-5.15.16/plugins:/home/bricked/.local/state/nix/profile/lib/qt-6/plugins:/etc/profiles/per-user/bricked/lib/qt-5.15.16/plugins:/etc/profiles/per-user/bricked/lib/qt-6/plugins:/nix/var/nix/profiles/default/lib/qt-5.15.16/plugins:/nix/var/nix/profiles/default/lib/qt-6/plugins:/run/current-system/sw/lib/qt-5.15.16/plugins:/run/current-system/sw/lib/qt-6/plugins:/home/bricked/.nix-profile/lib/qt-5.15.16/plugins:/home/bricked/.nix-profile/lib/qt-6/plugins

Image

Judging from the logs it seems to use kvantum, but it doesn't load the correct theme.

bricked-dev avatar Feb 26 '25 22:02 bricked-dev

Ohh there is a flatpak for dolphin nice Probably we need the help of some qt nerds The logs don't make any sense like kvantum is loading but then the style is still kde somehow

bohanubis avatar Feb 27 '25 01:02 bohanubis