Gtk-common-themes plug

From various examples, I’ve seen the following plug in a snapcraft.yaml file:

plugs:
  gnome-3-28-1804:
    interface: content
    target: gnome-platform
    default-provider: gnome-3-28-1804:gnome-3-28-1804
  gtk-3-themes:
    interface: content
    target: $SNAP/share/themes
    default-provider: gtk-common-themes:gtk-3-themes
  icon-themes:
    interface: content
    target: $SNAP/share/icons
    default-provider: gtk-common-themes:icon-themes
  sound-themes:
    interface: content
    target: $SNAP/share/sounds
    default-provider: gtk-common-themes:sounds-themes

But when I used that in my snapcraft.yaml file, the GTK icons for my app wouldn’t show.
So, I made a small change that fixed it. I had to modify the target path, so that it would point to: $SNAP/usr/share… (so I added /usr to the paths).

So mine looks like this now, and it works:

plugs:
  gnome-3-28-1804:
    interface: content
    target: gnome-platform
    default-provider: gnome-3-28-1804:gnome-3-28-1804
  gtk-3-themes:
    interface: content
    target: $SNAP/usr/share/themes
    default-provider: gtk-common-themes:gtk-3-themes
  icon-themes:
    interface: content
    target: $SNAP/usr/share/icons
    default-provider: gtk-common-themes:icon-themes
  sound-themes:
    interface: content
    target: $SNAP/usr/share/sounds
    default-provider: gtk-common-themes:sounds-themes

My question is: why did I need to change it to $SNAP/usr/share…to get it to show GTK icons? All the examples I’ve seen just have $SNAP/share… ? Am I doing this correctly?

My full snapcraft.yaml is:

name: openresizer # you probably want to 'snapcraft register <name>'
base: core18 # the base snap is the execution environment for this snap
version: '1.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: Batch image resizer with a GUI # 79 char long summary
description: |
  OpenResizer is an open-source batch image resizing software with a GUI.
  It is designed to be fast and easy-to-use.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

icon: gui/openresizer.png

architectures:
  - build-on: [amd64, i386]
    run-on: all



plugs:
  gnome-3-28-1804:
    interface: content
    target: gnome-platform
    default-provider: gnome-3-28-1804:gnome-3-28-1804
  gtk-3-themes:
    interface: content
    target: $SNAP/usr/share/themes
    default-provider: gtk-common-themes:gtk-3-themes
  icon-themes:
    interface: content
    target: $SNAP/usr/share/icons
    default-provider: gtk-common-themes:icon-themes
  sound-themes:
    interface: content
    target: $SNAP/usr/share/sounds
    default-provider: gtk-common-themes:sounds-themes



parts:

  desktop-gtk3:
    build-packages:
    - build-essential
    - libgtk-3-dev
    make-parameters:
    - FLAVOR=gtk3
    plugin: make
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: gtk
    stage-packages:
    - libxkbcommon0
    - ttf-ubuntu-font-family
    - dmz-cursor-theme
    - light-themes
    - adwaita-icon-theme
    - gnome-themes-standard
    - shared-mime-info
    - libgtk-3-0
    - libgdk-pixbuf2.0-0
    - libglib2.0-bin
    - libgtk-3-bin
    - unity-gtk3-module
    - libappindicator3-1
    - locales-all
    - xdg-user-dirs
    - ibus-gtk3
    - libibus-1.0-5
    - fcitx-frontend-gtk3
    override-build: |
      snapcraftctl build
      mkdir -pv $SNAPCRAFT_PART_INSTALL/gnome-platform


  main-part:
    # See 'snapcraft plugins'
    plugin: python
    python-packages:
      - pillow
    stage-packages:
      - python3-gi
      #- appmenu-gtk3-module

  openresizer:
    plugin: dump
    source: https://github.com/jrezai/openresizer.git
    source-type: git
    after: [desktop-gtk3]
    organize:
      glade_files: bin/glade_files
      gui: bin/gui
    override-pull: |
      snapcraftctl pull
      chmod +x bin/openresizer.py


apps:
  openresizer:
    command: desktop-launch $SNAP/bin/openresizer.py
    environment:
      XDG_DATA_DIRS: $SNAP/usr/share:$XDG_DATA_DIRS
    plugs: [gnome-3-28-1804, x11, unity7, pulseaudio, wayland, desktop, desktop-legacy, gsettings, home, removable-media]
    desktop: bin/gui/openresizer.desktop

Actually you should be using data-dir when using desktop-launch. See How to use the system GTK theme via the gtk-common-themes snap

Thanks for your reply. I changed it so that gnome-3-28-1804 points to data-dir, but now the GTK icons don’t show.

I changed it to:

plugs:
  gnome-3-28-1804:
    interface: content
    target: $SNAP/gnome-platform
    default-provider: gnome-3-28-1804:gnome-3-28-1804
  gtk-3-themes:
    interface: content
    target: $SNAP/data-dir/share/themes
    default-provider: gtk-common-themes:gtk-3-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/share/icons
    default-provider: gtk-common-themes:icon-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/share/sounds
    default-provider: gtk-common-themes:sounds-themes

But when I change it back to $SNAP/usr/share/.... the GTK icons show again. Should I leave it like that, since the GTK icons are showing? Or can this cause issues for some Snap installations?

It should actually be “target: $SNAP/data-dir/themes”, like this:

  gtk-3-themes:
    interface: content
    target: $SNAP/data-dir/themes
    default-provider: gtk-common-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes
1 Like