Gtk.css as symlink and how to deal with snapd?

Ubuntu Support Template

Ubuntu Version: 26.04

Desktop Environment (if applicable): COSMIC (should also happens on GNOME)

Problem Description:

I have this structure in my gtk-3.0config directory:

[heppen@dream-machines]$ ls -lah
total 16K
drwxrwxr-x  2 heppen heppen 4.0K Jul 11 21:23 .
drwxr-xr-x 19 heppen heppen 4.0K Jul 11 19:50 ..
-rw-rw-r--  1 heppen heppen   30 Jul 10 10:52 bookmarks
lrwxrwxrwx  1 heppen heppen   44 Jul 11 21:23 gtk.css -> /home/heppen/.config/gtk-4.0/cosmic/dark.css
-rw-rw-r--  1 heppen heppen  126 Jul 11 21:15 settings.ini

Unfortunately. This symlink cause issues with GTK themes in snap apps. They are not modified as it should. First issue from what I see, apparmor blocking access to this file.

Because of this:

Jul 11 21:25:08 dream-machines kernel: audit: type=1400 audit(1783797908.792:1286): apparmor="DENIED" operation="open" class="file" profile="snap.thunderbird.thunderbird" name="/home/heppen/.config/gtk-4.0/cosmic/dark.css" pid=79147 comm="thunderbird-bin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000

Relevant System Information:

I’m using my build of COSMIC desktop environment from my ppa: hepp3n/cosmic-epoch

There is settings daemon which modifies those specified in this template files when editing theme in COSMIC settings app. There is created symlink each time we modify theme.

It might be enough to make an apparmor profile for reading this file, so apps can access this path and it should solve the issue? There is path for ~/.config/gtk-3.0/gtk.css in apparmor but it’s not including symlinks I believe.

I’m not sure how to deal with apparmor tho. Do I need to create for each app a profile with allowing this paths?

I know when unlink this file and copy from final path to ~/.config/gtk-3.0/gtk.css makes theme works perfectly for snap apps. So it’s must be permission issue for sure.

Not exactly. First a theme snap of the theme must exist on snapcraft.io, and then it must be installed. Snaps can’t access system themes except via the gnome snap which can handle most, if not all, theme snaps. It will know what theme to use, but if it doesn’t find it, it defaults to adwaita.

Ah right. So it’s adw-gtk3 theme. When I toggle support for GTK apps in COSMIC settings. It’s just writes to gsettings adw-gtk3 as a theme and modifying gtk.css then.

I notice also. Snapd prompts for installing missing themes when this toggle is enabled :slight_smile:

I had this working somehow, before. Please look this post

Not sure to be honest, how I got this working tho :sweat_smile:

I tried to refresh few snaps, it might be snapd-desktop-integration + snapd itself. But it’s not working this time. Or something changed to adw-gtk3 or something else.

For that part of it I would ask on forum.snapcraft.io as general snap development/debugging is supported there. Snap is straight from Canonical as one of their products. While Ubuntu is also a Canonical product, it’s also a community project. That’s the focus here in this discourse as opposed to the snap forum.

2 Likes

I don’t know if the snap confinement could be an issue here, as well. There is an interface called personal-files for access to the ā€œdotā€ directories/files (~/.*). Since your symlink points to ~/.config/... the snap(s) in question need to be connected to it.

snap connect <plug>

<plug> has the format <snap>:<slot-name>, e.g. firefox:dot-mozilla-firefox. <slot-name> is a name for the interface connection of a snap, and it’s different for every snap. I’ve tried to snap connect firefox:personal-files, which didn’t work:

error: snap "firefox" has no plug named "personal-files"

Disclaimer: Don’t nail me on the snap terminology.

I reported this on snapcraft and they fixed!

For users interested in this change: sudo snap refresh –channel edge snapd and reboot :slight_smile:

4 Likes

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.