Hi, when trying to make a snap of MenuLibre, I can’t give it access to the host’s ~/.local/share/applications
and /usr/local/share/applications
.
The thing is, MenuLibre’s only goal is editing desktop files stored in ~/.local/share/applications
and /usr/local/share/applications
.
Is there a way to give my snap access to these specific directories or to use XDG_DATA_DIRS ? Currently, all of these directories point to the inside of the snap confinement, and not the user’s directories.
I’d very much like to not have to use the classic confinement or the personal-files interface, as it complicates the install for the end user.
Here is the snapcraft.yaml :
name: menulibre
base: core24 # 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: MenuLibre is an advanced FreeDesktop.org compliant menu editor.
description: |
MenuLibre is an advanced menu editor with modern features in a clean, easy-to-use interface. It lets you :
--> Create new launchers or modify existing ones with complete control and access to hidden settings
--> Add and adjust desktop actions: shortcuts to advanced application features
--> Easily rearrange the menu to suit your tastes
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: classic # use 'strict' once you have the right plugs and slots
layout:
/usr/share/lib/X11:
symlink: $SNAP/usr/share/lib/X11
/usr/lib/x86_64-linux-gnu/libgtk-3-0:
bind: $SNAP/usr/lib/x86_64-linux-gnu/libgtk-3-0t64
apps:
menulibre:
environment:
PYTHONPATH: $SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
GI_TYPELIB_PATH: $SNAP/usr/lib/x86_64-linux-gnu/girepository-1.0
GTK_IM_MODULE_FILE: /usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0
command: bin/menulibre
command-chain: [bin/desktop-launch]
plugs:
- home
- dekstop
- x11
- wayland
- gsettings
parts:
desktop-gtk3:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: gtk
plugin: make
make-parameters: ["FLAVOR=gtk3"]
build-packages:
- build-essential
- libgtk-3-dev
stage-packages:
- libxkbcommon0 # XKB_CONFIG_ROOT
- fonts-ubuntu
- dmz-cursor-theme
- light-themes
- adwaita-icon-theme
- gnome-themes-extra
- 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
- xkb-data
menulibre:
plugin: python
source: https://github.com/bluesabre/menulibre.git
build-packages:
- gir1.2-gtk-3.0
- intltool
- libgnome-menu-3-dev
- python-gi-dev
- python3
- python3-distutils-extra
- python3-psutil
stage-packages:
- gir1.2-gdkpixbuf-2.0
- gir1.2-glib-2.0
- gir1.2-gmenu-3.0
- gir1.2-gtk-3.0
- gir1.2-gtksource-3.0
- gobject-introspection
- gnome-menus
- python3
- python3-gi
- python3-psutil
- xdg-utils
override-build: |
set -eux
python3 setup.py build
mkdir -p $SNAPCRAFT_PART_INSTALL/bin
cp -r /root/parts/menulibre/build/bin/* $SNAPCRAFT_PART_INSTALL/bin/
cp -r /root/parts/menulibre/build/* $SNAPCRAFT_PART_INSTALL/
Thanks in advance !
ogra
January 19, 2025, 2:49pm
2
Take a look at the personal-files and system-files interfaces…
Thanks for the tip !
Once setup, if this snap were to be published on the snap store, would it be needed for people to execute a command like snap connect menulibre:personal-files
as personal-files and system-files don’t have auto-connect ?
ogra
January 20, 2025, 8:33am
4
When you use these interfaces your snap will go into manual review and you will have to file a store-review request to get their use granted, in that post you can additionally ask for auto-connection (and convince the reviewers that this makes sense for your application in the discussion)
Okay, thank you for the clarification.
I did configure personal-files and system-files, but so far the snap still doesn’t have access to the host’s directories.
Here is my snapcraft :
base: core24 # 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: MenuLibre is an advanced FreeDesktop.org compliant menu editor.
description: |
MenuLibre is an advanced menu editor with modern features in a clean, easy-to-use interface. It lets you :
--> Create new launchers or modify existing ones with complete control and access to hidden settings
--> Add and adjust desktop actions: shortcuts to advanced application features
--> Easily rearrange the menu to suit your tastes
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
layout:
/usr/share/lib/X11:
symlink: $SNAP/usr/share/lib/X11
/usr/lib/x86_64-linux-gnu/libgtk-3-0:
bind: $SNAP/usr/lib/x86_64-linux-gnu/libgtk-3-0t64
plugs:
dot-local-share:
interface: personal-files
read: [$HOME/.local/share/applications]
write: [$HOME/.local/share/applications]
read: [$HOME/.local/share/icons]
write: [$HOME/.local/share/icons]
usr-share-r:
interface: system-files
read:
- /usr/share/applications
apps:
menulibre:
environment:
PYTHONPATH: $SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
GI_TYPELIB_PATH: $SNAP/usr/lib/x86_64-linux-gnu/girepository-1.0
GTK_IM_MODULE_FILE: /usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0
command: bin/menulibre
command-chain: [bin/desktop-launch]
plugs:
- home
- x11
- wayland
- gsettings
- dot-local-share
#- usr-share-r
parts:
desktop-gtk3: #replacement to the gnome extension, as it caused issues with the building process
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: gtk
plugin: make
make-parameters: ["FLAVOR=gtk3"]
build-packages:
- build-essential
- libgtk-3-dev
stage-packages:
- libxkbcommon0
- fonts-ubuntu
- dmz-cursor-theme
- light-themes
- adwaita-icon-theme
- gnome-themes-extra
- 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
- xkb-data
menulibre:
plugin: python
source: https://github.com/bluesabre/menulibre.git
build-packages:
- gir1.2-gtk-3.0
- intltool
- libgnome-menu-3-dev
- python-gi-dev
- python3
- python3-distutils-extra
- python3-psutil
stage-packages:
- gir1.2-gdkpixbuf-2.0
- gir1.2-glib-2.0
- gir1.2-gmenu-3.0
- gir1.2-gtk-3.0
- gir1.2-gtksource-3.0
- gobject-introspection
- gnome-menus
- python3
- python3-gi
- python3-psutil
- xdg-utils
override-build: |
set -eux
python3 setup.py build
mkdir -p $SNAPCRAFT_PART_INSTALL/bin
cp -r /root/parts/menulibre/build/bin/* $SNAPCRAFT_PART_INSTALL/bin/
cp -r /root/parts/menulibre/build/* $SNAPCRAFT_PART_INSTALL/
Once installed, I executed snap connect menulibre:dot-local-share-r ; snap connect menulibre:usr-share-r
just in case.
As you can see here, it really doesn’t work !
loic@Ubuntu:~$ ls ~/.local/share ; ls /usr/share
akonadi evolution icons kpeoplevcard net.lrclib.lrcget sounds
akonadi-davgroupware flatpak kactivitymanagerd krunnerstaterc notes Steam
akonadi_migration_agent folks kate kscreen okular suyu
applications gnome-settings-daemon kded6 kwalletd org.gnome.TextEditor Trash
apps gnome-shell kdenlive kwrite 'Paradox Interactive' umu
ark gnome-software keyrings libkunitconversion pitivi user-places.xbel
backgrounds Google khelpcenter local-mail pixmaps user-places.xbel.bak
baloo gstreamer-1.0 kio LRCGET plasma-systemmonitor user-places.xbel.tbcache
com.example.harmonymusic gvfs-metadata klipper man recently-used.xbel 'Valve Corporation'
contacts gwenview knewstuff3 mime remoteview vlc
dbus-1 harmonymusic konsole nano sddm vulkan
desktop-directories hotspotshield kontact nautilus servicemenu-download yelp
dolphin ibus-table kpat nautilus-python session_migration-ubuntu
elisa icc kpeople nemo-python snapcraft
accountsservice dns gnome-session kdump-tools nvidia-prime sounds
aclocal dnsmasq-base gnome-settings-daemon keyrings opencc source-highlight
aclocal-1.16 doc gnome-shell language-selector openvpn spa-0.2
aisleriot doc-base gnome-system-monitor language-support orca speech-dispatcher
alsa dot.bashrc gnome-text-editor language-tools org.gnome.Characters ssl-cert
alsa-base dot.profile gnome-tweaks libcaca org.gnome.Weather sssd
alsa-card-profile dot.profile.md5sums gnupg libc-bin os-prober staff-group-for-usr-local
appimagelauncher dpkg groff libchewing ostree swcatalog
applications drirc.d grub libdebuginfod-common p11-kit system-config-printer
apport egl gst-plugins-base libdrm PackageKit systemd
appstream emacs gstreamer-1.0 libgcrypt20 pam systemtap
apt-file emacsen-common gtk-3.0 libgedit-gtksourceview-300 pam-configs tabset
aspell enchant-2 gtk-4.0 libgweather-4 perl tcltk
autoconf evince gtk-doc libinput perl5 terminfo
automake-1.16 evolution-data-server gtk-engines liblouis perl-openssl-defaults themes
avahi figlet gtksourceview-2.0 liblouisutdml pipewire thumbnailers
backgrounds file gtksourceview-3.0 libmysofa pixmaps tracker3
base-files finalrd gtksourceview-4 libthai pkgconfig tracker3-miners
base-passwd fish gtksourceview-5 libwacom plymouth ubuntu
bash-completion flatpak guile lightdm pnm2ppa ubuntu-drivers-common
beets fontconfig gupnp-av lintian pocketsphinx ubuntu-release-upgrader
binfmts fonts gupnp-dlna-2.0 linux-sound-base polkit-1 ubuntu-wayland
bpfcc-tools fonts-droid-fallback gvfs locale poppler ucf
brltty foo2qpdl help locale-langpack ppd ufw
bug foo2zjs help-langpack locales ppdc unattended-upgrades
build-essential fwupd hotspotshield lto-disabled-list ppp unity
ca-certificates gamemode hplip m17n profile upstart
cmake gcc hunspell m2300w profile.md5sums usb_modeswitch
color GConf hwdata makedumpfile publicsuffix user-session-migration
colord gdb i18n man pyshared util-linux
common-licenses gdm ibus maven-repo python3 vim
consolefonts gettext ibus-table menu python-apt vulkan
console-setup gettext-0.22.5 icons metainfo python-babel-localedata vulkansc
consoletrans ghostscript ieee-data mime qt5 w3m
cups gir-1.0 ImageMagick-6 misc readline wayland-sessions
dbus-1 git-core im-config mobile-broadband-provider-info rsync wireplumber
dconf gitweb info ModemManager rsyslog X11
debconf glade info.dir motd rygel xdg-desktop-portal
debhelper glib-2.0 initramfs-tools mousetweaks screen-resolution-extra xdg-terminals
debianutils glvnd installed-tests myspell seahorse xml
defaults gnome intltool nano secureboot xml-core
desktop-directories gnome-background-properties ipp-usb nautilus session-migration xsessions
dhcpcd gnome-bluetooth-3.0 iproute2 nautilus-python sgml zoneinfo
dict gnome-browser-connector iptables netpbm sgml-base zsh
dictionaries-common gnome-control-center iso-codes netplan snapd
distro-info gnome-initial-setup java networks snmp
djvu gnome-remote-desktop javascript nvidia software-properties
loic@Ubuntu:~$ snap run --shelle menulibre
erreur : unknown flag `shelle'
loic@Ubuntu:~$ snap run --shell menulibre
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
loic@Ubuntu:/home/loic$ ls ~/.local/share ; ls /usr/share
desktop-directories icons mime themes
applications dbus-1 dot.bashrc gcc libc-bin motd pam-configs python3 staff-group-for-usr-local vim
base-files debhelper dot.profile glib-2.0 libdrm netplan pixmaps readline subiquity xml
base-passwd debianutils dot.profile.md5sums icons libgcrypt20 networks pkgconfig secureboot systemd xml-core
bash-completion dhcpcd dpkg initramfs-tools locale opensc plymouth sensible-utils tabset zoneinfo
binfmts dict finalrd iptables man openssh polkit-1 sgml terminfo
ca-certificates distro-info fontconfig keyrings menu p11-kit profile sgml-base ucf
common-licenses doc fonts lib misc pam profile.md5sums snappy util-linux
Did I forget to configure something ? An environment variable maybe ?
ogra
January 20, 2025, 2:00pm
6
you are using it wrong
try using the actual full path the interface grants, not a dir above it (i.e. if your interface grants ~/.local/share/applications you need to use that exact path)
Hi, I corrected the snapcraft.yaml to point to the exact host directories I want accessible by my snap, but it still doesn’t do anything.
Here is the plugs part of my snapcraft :
plugs:
user-applications:
interface: personal-files
read: [$HOME/.local/share/applications]
write: [$HOME/.local/share/applications]
user-icons:
interface: personal-files
read: [$HOME/.local/share/icons]
write: [$HOME/.local/share/icons]
system-applications:
interface: system-files
read: [/usr/share/applications]
write: [/usr/share/applications]
system-icons:
interface: system-files
read: [/usr/share/icons]
write: [/usr/share/icons]
and here is the ls for these directories, both in snap environment and on host :
loic@Ubuntu:~/Téléchargements/Snapcraft/menulibre$ snap run --shell menulibre
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
loic@Ubuntu:/home/loic/Téléchargements/Snapcraft/menulibre$ ls $HOME/.local/share/icons
loic@Ubuntu:/home/loic/Téléchargements/Snapcraft/menulibre$ ls $HOME/.local/share/applications
ls: cannot access '/home/loic/snap/menulibre/x1/.local/share/applications': No such file or directory
loic@Ubuntu:/home/loic/Téléchargements/Snapcraft/menulibre$ ls /usr/share/applications
mimeapps.list python3.12.desktop vim.desktop xdg-open.desktop
loic@Ubuntu:/home/loic/Téléchargements/Snapcraft/menulibre$ /usr/share/icons
bash: /usr/share/icons: Is a directory
loic@Ubuntu:~/Téléchargements/Snapcraft/menulibre$ ls ~/.local/share/icons ; ls ~/.local/share/applications/
hicolor
'Anno 1800.desktop'
appimagekit_3c274332152706b8c487d142d7071a8e-Beeper.desktop
ch.protonmail.protonmail-bridge.desktop
com.mattjakeman.ExtensionManager.desktop
'Crusader Kings III.desktop'
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_msaccess.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_msword.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-excel.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-excel.sheet.binary.macroEnabled.12.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-excel.sheet.macroEnabled.12.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-excel.template.macroEnabled.12.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-powerpoint.addin.macroEnabled.12.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-powerpoint.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-powerpoint.presentation.macroEnabled.12.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-powerpoint.slideshow.macroEnabled.12.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-powerpoint.template.macroEnabled.12.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-word.document.macroEnabled.12.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.ms-word.template.macroEnabled.12.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.openxmlformats-officedocument.presentationml.presentation.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.openxmlformats-officedocument.presentationml.slideshow.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.openxmlformats-officedocument.presentationml.template.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.openxmlformats-officedocument.spreadsheetml.sheet.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.openxmlformats-officedocument.spreadsheetml.template.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.openxmlformats-officedocument.wordprocessingml.document.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_vnd.openxmlformats-officedocument.wordprocessingml.template.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:application_x-crossover-msg.desktop
cxassoc-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24:text_xml.desktop
'cxmenu-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24-2gmh07f-Centre de téléchargement Office.desktop'
'cxmenu-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24-2gmh07f-Préférences linguistiques d’Office.desktop'
cxmenu-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24-3ii0rqp-Access.desktop
cxmenu-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24-3ii0rqp-Excel.desktop
'cxmenu-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24-3ii0rqp-Microsoft OneDrive.desktop'
'cxmenu-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24-3ii0rqp-OneNote 2016.desktop'
cxmenu-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24-3ii0rqp-Outlook.desktop
cxmenu-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24-3ii0rqp-PowerPoint.desktop
cxmenu-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24-3ii0rqp-Publisher.desktop
cxmenu-cxoffice-0eabd925-7546-4755-917a-b15bfaed4a24-3ii0rqp-Word.desktop
'Deep Rock Galactic.desktop'
defaults.list
'Hell Let Loose.desktop'
'Jeux--Battlefield 4--1736688157.573159.desktop'
'Jeux--EA Client--1736686785.892143.desktop'
Jeux--Storyteller--1736605974.602568.desktop
'Jeux--Terra Nil--1736605976.19806.desktop'
'Jeux--Thank Goodness You'\''re Here!--1736605974.579972.desktop'
mimeinfo.cache
nvidia-settings.desktop
org.gnome.Shell.Extensions.GSConnect.desktop
org.gnome.Shell.Extensions.GSConnect.Preferences.desktop
org.videolan.VLC.desktop
Sifu.desktop
steam.desktop
thunderbird_thunderbird.desktop
transmission_transmission.desktop
vlc.desktop
wine
Before executing these commands I did manually connect the said plugs.
I looked at some other yaml files that used these interfaces, and I don’t see any difference (syntax wise) with my implementation.
Am I missing on something ? I’m sorry, I’m new to the snap building.
ogra
January 20, 2025, 3:53pm
8
$HOME points to the snaps home ($SNAP_USER_DATA) by default … try /home/loic/.local/share/applications instead
1 Like
ogra
January 20, 2025, 4:05pm
9
also, note that write implies read so you can drop the read:
lines for the ones you want to have write for …
1 Like
Right thanks I can now access /home/$USER/.local/share/application ! How can I bind /home/$USER/.local/share/application to $HOME/.local/share/application ? I know that layouts won’t work for this due to technical limitations, and i tried to put XDG_DATA_HOME: /home/$USER/.local/share:$XDG_DATA_HOME
as a variable, but it didn’t work.
Also, weirdly enough, my host’s /usr/share/application is still not exposed to the snap, despite the system-files interface being set up.
To make the snap environment’s ~/.local/share/applications be /home/$USER/.local/share/applications, I had to create a configure
hook containing a command to created a symlink between the two directories.
Sadly, I now need to grant access to the host’s $PATH, so I guess I can only make a classic snap now !