WARNING: Use at your own risk. This is NOT a supported configuration and you’ll want to turn this off and re-test before reporting any bugs. (i.e. Report bugs gtk3-nocsd fixes, not ones it causes.)
OK, so you’ve got a desktop that’s using gtk3-nocsd and a GTK app that renders fine outside Flatpak, but does something unacceptably CSD-ish inside Flatpak. (For me, it’s non-GNOME GTK-using applications like Deluge displaying big black borders on things like context menus when KWin’s compositing is disabled.)
The Flatpak developers don’t appear to see this as an issue, and not all applications have a good Qt-based counterpart, so what’s a stubborn “It’s my ****ing computer” person supposed to do?
…what about taking advantage of how Flatpak applications were already probably printing this to the terminal every time you launched them?
ERROR: ld.so: object 'libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
Here’s how you shoe-horn your gtk3-nocsd into Flatpak without rebuilding the Flatpak Runtime or the application package:
- Create a folder that Flatpak isn’t going to overlay, like
/gtk3-nocsdand make sure it’s got the same
0755 root:rootpermissions as anything else nobody but root should be able to muck in.
sudo cp -p /usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 /gtk3-nocsd(substitute whatever path your host distro uses for the original, non-symlinked library file and note the
-pto preserve the permissions and ownership. You need the sticky bit to pass certain safety checks.)
- Go into Flatseal or use
flatpak overrideand grant your application filesystem access to
/gtk3-nocsd:ro, then add an environment variable override to
Congratulations. For better or for worse, you should now have your Flatpak’d application loading gtk3-nocsd like an un-Flatpak’d application. It seems to have solved the “big black borders on context menus with compositing disabled” issue in Deluge-GTK for me… but I make no guarantees that it’ll work for you.
You can check if it’s getting loaded by:
flatpak enter <app ID> sh
ps axto get the PID of the process (probably
2in my experience)
grep nocsd /proc/<PID>/maps
In theory, you could do this in Flatseal’s “All Applications” tab, but why tempt fate. Do as I did. Apply it selectively to just the applications that exhibit problems.
I doubt the Flatpak devs will ever enable
ld.so‘s secure execution mode, since it disables
LD_LIBRARY_PATH, which is used in some launcher scripts to make some applications find their libraries under
/app rather than
/usr/lib (I had to use it to get a custom build of SDL_mixer to find libmodplug at runtime even though it found it without issue at compile time) but, if so, the next step would be to try injecting
/var/lib/flatpak/runtime/org.freedesktop.Platform/x86_64/<VERSION>/active/files/lib/ so it’ll show up in the list of standard paths
ld.so‘s secure mode is whitelisted to.