Overview
I created a snap for an electron app qqmusic for linux. It’s already packed in .deb
package, and works correctly if install the deb package directly. I snapped it, and most stuff work correctly, however, I cannot get the systray icon working properly. There should be a menu showed up if single-click on the systray icon, but nothing happened, the double-click to hide/show the main window of qqmusic does work correctly however.
here is the snapcraft.yaml
(GitHub - twang2218/qqmusic-snap: qqmusic-snap):
name: qqmusic
base: core18
version: '1.1.1'
summary: QQ Music for Linux
description: |
QQ Music provides massive high-quality music for you.
# grade: stable
grade: devel
confinement: strict
architectures:
- build-on: amd64
parts:
qqmusic:
plugin: dump
source: https://dldir1.qq.com/music/clntupate/linux/deb/qqmusic_1.1.1_amd64.deb
source-type: deb
override-pull: |
snapcraftctl pull
# Fix the name
sed -i -e 's|Name=qqmusic|Name=QQ Music\nName[zh]=QQ音乐|g' usr/share/applications/qqmusic.desktop
# Fix the executable's location
sed -i -e 's|Exec=/opt/qqmusic/qqmusic %U|Exec=qqmusic %U|g' usr/share/applications/qqmusic.desktop
# Point icon to the correct location
sed -i -e 's|Icon=qqmusic|Icon=${SNAP}/usr/share/icons/hicolor/256x256/apps/qqmusic.png|g' usr/share/applications/qqmusic.desktop
stage-packages:
- libgtk-3-0
- libnotify4
- libnss3
- libxss1
- libxtst6
- xdg-utils
- libatspi2.0-0
- libuuid1
- libappindicator3-1
- libsecret-1-0
- libx11-xcb1
- libasound2
- dbus-x11
# for /usr/bin/whereis
- util-linux
apps:
qqmusic:
command: desktop-launch $SNAP/opt/qqmusic/qqmusic --no-sandbox
environment:
# Correct the TMPDIR path for Chromium Framework/Electron to ensure
# libappindicator has readable resources.
TMPDIR: $XDG_RUNTIME_DIR
extensions:
- gnome-3-34
plugs:
# desktop
- desktop
- desktop-legacy
- wayland
- unity7
- x11
- opengl
# electron
- browser-support
- gsettings
# - home
- network
# audio
- alsa
- jack1
- pulseaudio
- audio-playback
# - audio-record
# others
- avahi-observe
- screen-inhibit-control
- upower-observe
- bluez
slots:
- mpris
Compare the devmode
vs strict
mode
The systray works correctly in devmode
, but cannot work properly in strict
mode. here is what I tried.
Installed in devmode
sudo snap install --devmode ./qqmusic_1.1.1_amd64.snap
Verify the mode:
➜ snap info --verbose qqmusic
name: qqmusic
summary: QQ Music for Linux
health:
status: unknown
message: health has not been set
publisher: –
license: unset
description: |
QQ Music provides massive high-quality music for you.
commands:
- qqmusic
notes:
private: false
confinement: strict
devmode: true
jailmode: false
trymode: false
enabled: true
broken: false
ignore-validation: false
base: core18
refresh-date: yesterday at 20:10 AEST
installed: 1.1.1 (x1) 110MB devmode
Launch the qqmusic
via cli
➜ qqmusic
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Gtk-Message: 14:24:41.446: Failed to load module "canberra-gtk-module"
Gtk-Message: 14:24:41.465: Failed to load module "canberra-gtk-module"
(electron) The default value of app.allowRendererProcessReuse is deprecated, it is currently "false". It will change to be "true" in Electron 9. For more information please check https://github.com/electron/electron/issues/18397
(node:497255) UnhandledPromiseRejectionWarning: undefined
(node:497255) UnhandledPromiseRejectionWarning: undefined
(node:497255) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:497255) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:497255) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:497255) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
login refresh fail
(node:497255) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(node:497255) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(electron) 'setUserAgent function' is deprecated and will be removed. Please use 'userAgent property' instead.
At the same time, the /var/log/kern.log
content is following:
Sep 17 14:24:42 purrbuntu kernel: [353140.318443] audit: type=1107 audit(1631852682.480:1015366): pid=1682 uid=103 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=497255 label="snap.qqmusic.qqmusic" peer_pid=1677 peer_label="unconfined"
Sep 17 14:24:42 purrbuntu kernel: [353140.318443] exe="/usr/bin/dbus-daemon" sauid=103 hostname=? addr=? terminal=?'
Sep 17 14:24:43 purrbuntu kernel: [353141.066130] audit: type=1326 audit(1631852683.228:1015367): auid=1000 uid=1000 gid=1000 ses=3 pid=497255 comm="qqmusic" exe="/snap/qqmusic/x1/opt/qqmusic/qqmusic" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7efc3aaa04b7 code=0x7ffc0000
Sep 17 14:24:43 purrbuntu kernel: [353141.126718] audit: type=1107 audit(1631852683.288:1015368): pid=1682 uid=103 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=497255 label="snap.qqmusic.qqmusic" peer_pid=1677 peer_label="unconfined"
Sep 17 14:24:43 purrbuntu kernel: [353141.126718] exe="/usr/bin/dbus-daemon" sauid=103 hostname=? addr=? terminal=?'
Sep 17 14:24:45 purrbuntu kernel: [353143.008397] audit: type=1326 audit(1631852685.168:1015369): auid=1000 uid=1000 gid=1000 ses=3 pid=497400 comm="qqmusic" exe="/snap/qqmusic/x1/opt/qqmusic/qqmusic" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7f7dfff764b7 code=0x7ffc0000
And the systray icon works correctly.
Installed in strict
/dangerous
mode
sudo snap install --dangerous ./qqmusic_1.1.1_amd64.snap
The mode can be verified by CLI:
➜ snap info --verbose qqmusic
name: qqmusic
summary: QQ Music for Linux
health:
status: unknown
message: health has not been set
publisher: –
license: unset
description: |
QQ Music provides massive high-quality music for you.
commands:
- qqmusic
notes:
private: false
confinement: strict
devmode: false
jailmode: false
trymode: false
enabled: true
broken: false
ignore-validation: false
base: core18
refresh-date: today at 14:29 AEST
installed: 1.1.1 (x1) 110MB -
Launch the qqmusic
from command line:
➜ qqmusic
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Gtk-Message: 14:32:50.482: Failed to load module "canberra-gtk-module"
Gtk-Message: 14:32:50.485: Failed to load module "canberra-gtk-module"
(electron) The default value of app.allowRendererProcessReuse is deprecated, it is currently "false". It will change to be "true" in Electron 9. For more information please check https://github.com/electron/electron/issues/18397
(node:501785) UnhandledPromiseRejectionWarning: undefined
(node:501785) UnhandledPromiseRejectionWarning: undefined
(node:501785) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:501785) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:501785) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:501785) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
login refresh fail
(node:501785) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(node:501785) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
stderr: dbus-monitor: unable to enable new-style monitoring: org.freedesktop.DBus.Error.AccessDenied: "An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.18543" (uid=1000 pid=501935 comm="dbus-monitor --session type='signal',interface='or" label="snap.qqmusic.qqmusic (enforce)") interface="org.freedesktop.DBus.Monitoring" member="BecomeMonitor" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)". Falling back to eavesdropping.
(electron) 'setUserAgent function' is deprecated and will be removed. Please use 'userAgent property' instead.
The /var/log/kern.log
output for the launch is:
Sep 17 14:32:50 purrbuntu kernel: [353628.627303] audit: type=1107 audit(1631853170.758:1015479): pid=1682 uid=103 auid=4294967295 ses=4294967295 msg='apparmor="DENIED" operation="dbus_method_call" bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=501785 label="snap.qqmusic.qqmusic" peer_pid=1677 peer_label="unconfined"
Sep 17 14:32:50 purrbuntu kernel: [353628.627303] exe="/usr/bin/dbus-daemon" sauid=103 hostname=? addr=? terminal=?'
Sep 17 14:32:50 purrbuntu kernel: [353628.748537] audit: type=1326 audit(1631853170.882:1015480): auid=1000 uid=1000 gid=1000 ses=3 pid=501785 comm="qqmusic" exe="/snap/qqmusic/x1/opt/qqmusic/qqmusic" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7f6d221ff4b7 code=0x50000
Sep 17 14:32:51 purrbuntu kernel: [353629.560219] audit: type=1326 audit(1631853171.694:1015481): auid=1000 uid=1000 gid=1000 ses=3 pid=501921 comm="qqmusic" exe="/snap/qqmusic/x1/opt/qqmusic/qqmusic" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7f4e52b624b7 code=0x50000
And nothing happened if click on the qqmusic systray icon.
Potential Problem
The bluez
error should not be the problem, I can overcome it by connecting it to bluez
interface, and the result is the same.
The following error caught my eyes, and I’m not sure whether it’s the cause of the problem:
stderr: dbus-monitor: unable to enable new-style monitoring: org.freedesktop.DBus.Error.AccessDenied: "An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.18543" (uid=1000 pid=501935 comm="dbus-monitor --session type='signal',interface='or" label="snap.qqmusic.qqmusic (enforce)") interface="org.freedesktop.DBus.Monitoring" member="BecomeMonitor" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)". Falling back to eavesdropping.
I cannot find any interface
corresponding to dbus org.freedesktop.DBus.Monitoring
, so can any one give me a help on how to solve the problem? Thanks.