$SNAP_DATA
is owned by root
, it’s usually used if the application is a system daemon. While you can use it to also store data that might be sharable by all users on the system, my guess here is you likely actually meant $SNAP_USER_DATA
(which would point to $HOME/snap/...
). If you did genuinely mean $SNAP_DATA
, you’d have to set up the permissions on the folder properly in advance (via hooks
, such as the install
hook).
I do personally have a fix for the web browser issue with Java applications, though I don’t think there’s a standardised approach for it. In Flathub, they rebuild the entire JVM to incorporate a patch for it. Personally, I take advantage of the Java Modules system to replace the class file that’s responsible for the Linux integration so that it works better with Snaps.
Take a look here and download the patch + source (Java’s GPL, sorry, I’d very much recommend bundling both in your snap just to satisfy the license requirements). It’s very important that the class file in compiled/java.desktop/sun/awt/X11
stays in a folder with the path of compiled/java.desktop/sun/awt/X11
, it’s how Java is going to know what to replace. Also, this is built for Ubuntu’s OpenJDK 11 (default-jre
on core20
), I have’t tested if it’d work on different Java versions.
Once it’s in your snap image, you can make Java use it with --patch-module java.desktop=$SNAP/java-patches/compiled/java.desktop
(so basically, it’s important that java.desktop
is part of the path, but the leading path doesn’t matter).
The advantage of doing it with the module system is that if there’s any patches to Java in the future, you don’t have to recompile Java everytime, just rebuild your snap and the patch should keep going.
The Gnome Extensions wouldn’t have fixed this issue, but you could still consider using them anyway. You can eliminate a lot of the bloat they add with a cleanup
part, which would look something like
cleanup:
plugin: nil
build-snaps:
- core20
- gnome-3-38-2004
override-prime: |
set -eux
for snap in "core20" "gnome-3-38-2004"; do
cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \;
done
after: [my_part_1, my_part_2, etc]
This way you benefit from the advantages of the extension yet eliminate the majority of the downside of the file size inflation. ( Admiteddly the benefits might not be great for what’s effectively a browser based environment )