Skip to content

Commit bae08f8

Browse files
authored
Merge pull request #63 from realnc/improve-hook-script
Add gtk3 and xdgdesktopportal in apprun hook
2 parents 7bc321e + d245b4d commit bae08f8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/deployment.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,21 @@ inline bool createAppRunHook(appdir::AppDir &appDir) {
9292
return false;
9393
}
9494

95+
// Old Qt versions only ship gtk2, new versions only gtk3. No Qt version had both.
96+
const bool haveGtk3 = bf::exists(appDir.path() / "usr/plugins/platformthemes" / "libqgtk3.so");
97+
9598
ofs << "# generated by linuxdeploy-plugin-qt" << std::endl
9699
<< std::endl
97-
<< "# try to make Qt apps more \"native looking\", if possible" << std::endl
98-
<< "# see also https://github.com/AppImage/AppImageKit/issues/977#issue-462374883" << std::endl
99-
<< "# and https://github.com/AppImage/AppImageKit/issues/977#issue-462374883" << std::endl
100+
<< "# try to make Qt apps more \"native looking\" on Gtk-based desktops, if possible" << std::endl
101+
<< "# on other desktops, use the XDG Desktop Portal plugin instead to get native dialogs" << std::endl
102+
<< "# see https://github.com/AppImage/AppImageKit/issues/977#issue-462374883" << std::endl
103+
<< "# and https://github.com/linuxdeploy/linuxdeploy-plugin-qt/pull/63" << std::endl
100104
<< "case \"${XDG_CURRENT_DESKTOP}\" in" << std::endl
101105
<< " *GNOME*|*gnome*|*XFCE*)" << std::endl
102-
<< " export QT_QPA_PLATFORMTHEME=gtk2" << std::endl
106+
<< " export QT_QPA_PLATFORMTHEME=" << (haveGtk3 ? "gtk3" : "gtk2") << std::endl
107+
<< " ;;" << std::endl
108+
<< " *)" << std::endl
109+
<< " export QT_QPA_PLATFORMTHEME=xdgdesktopportal" << std::endl
103110
<< " ;;" << std::endl
104111
<< "esac" << std::endl;
105112

0 commit comments

Comments
 (0)