tmccabe
September 10, 2021, 9:16pm
1
I’ve developed a Snapcraft application using PyQt5. It has a tray icon with a menu. The tray icon shows up great, just like it should, in every Linux flavor I’ve tried except for Ubuntu Budgie (which I’m running on a Mac in a Parallels VM).
You can see the details on my question, including a minimal reproducible example, on Stack Overflow here:
https://stackoverflow.com/questions/69138044/how-to-make-tray-icon-display-in-ubuntu-budgie-in-snapcraft-pyqt5-app
Any suggestions for how I can get the tray icon to work on Ubuntu Budgie like it does everywhere else?
Can you confirm if other applications who uses QSystemTrayIcon shows up system tray icon on Budgie Desktop Env? You can natively try installing qbittorrent for example to check they work, or https://snapcraft.io/notifier-for-snapcraft/ using snap, both applications uses QSystemTrayIcon class.
1 Like
tmccabe
September 13, 2021, 3:47pm
3
The app at https://snapcraft.io/qbittorrent-arnatious has the same problem. Attached is an image displaying it.
Snap Herald also has the same issue. Attached is another screenshot.
1 Like
Can you test qbittorrent non snap version to see if it is the issue with the tray and not with the app?
1 Like
tmccabe
September 14, 2021, 12:27pm
5
Same problem. After uninstalling the snap version and restarting, I ran the following:
sudo add-apt-repository ppa:qbittorrent-team/qbittorrent-stable
sudo apt-get update && sudo apt-get install qbittorrent
And as you can see from the screenshot, there is no icon in this version either.
ogra
September 14, 2021, 1:31pm
6
any errors or denials you could see by starting the app from a terminal window, watching the journal etc etc ?
tmccabe
September 14, 2021, 1:34pm
7
Which app, and what do you mean by “journal”? I’ve started my snapped testapp
using the terminal and saw no errors in Budgie even though the icon did not display.
ogra
September 14, 2021, 1:35pm
8
i mean running journalctl -f
in a second terminal window while you start your app (and watch out for lines related to the app)
1 Like
tmccabe
September 14, 2021, 1:52pm
9
I ran journalctl -f
in one terminal and the snapped testapp
in the other on Budgie, and the icon didn’t show (as expected). Here is the output from journalctl -f
. I don’t think any of it is relevant to the icon issue…?
Sep 14 09:48:07 ubuntubudgie systemd[3071]: Started snap.testapp.testapp.ef756571-d723-475c-ba0e-a819e08c7488.scope.
Sep 14 09:48:07 ubuntubudgie audit[5536]: AVC apparmor="DENIED" operation="capable" profile="/snap/snapd/12883/usr/lib/snapd/snap-confine" pid=5536 comm="snap-confine" capability=4 capname="fsetid"
Sep 14 09:48:07 ubuntubudgie kernel: audit: type=1400 audit(1631627287.918:65): apparmor="DENIED" operation="capable" profile="/snap/snapd/12883/usr/lib/snapd/snap-confine" pid=5536 comm="snap-confine" capability=4 capname="fsetid"
Sep 14 09:48:07 ubuntubudgie systemd[1]: tmp-snap.rootfs_5R1o8L.mount: Succeeded.
Sep 14 09:48:07 ubuntubudgie systemd[3071]: tmp-snap.rootfs_5R1o8L.mount: Succeeded.
Sep 14 09:48:08 ubuntubudgie audit[5629]: AVC apparmor="DENIED" operation="open" profile="snap.testapp.testapp" name="/media/psf/Home/Documents/" pid=5629 comm="head" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie kernel: audit: type=1400 audit(1631627288.390:66): apparmor="DENIED" operation="open" profile="snap.testapp.testapp" name="/media/psf/Home/Documents/" pid=5629 comm="head" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie audit[5648]: AVC apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Documents/" pid=5648 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie kernel: audit: type=1400 audit(1631627288.406:67): apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Documents/" pid=5648 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie audit[5650]: AVC apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Desktop/" pid=5650 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie kernel: audit: type=1400 audit(1631627288.410:68): apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Desktop/" pid=5650 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie audit[5652]: AVC apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Downloads/" pid=5652 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie kernel: audit: type=1400 audit(1631627288.414:69): apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Downloads/" pid=5652 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie audit[5654]: AVC apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Music/" pid=5654 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie kernel: audit: type=1400 audit(1631627288.422:70): apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Music/" pid=5654 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie audit[5656]: AVC apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Pictures/" pid=5656 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie audit[5658]: AVC apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Movies/" pid=5658 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie kernel: audit: type=1400 audit(1631627288.426:71): apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Pictures/" pid=5656 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:08 ubuntubudgie kernel: audit: type=1400 audit(1631627288.426:72): apparmor="DENIED" operation="rmdir" profile="snap.testapp.testapp" name="/media/psf/Home/Movies/" pid=5658 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=1000 ouid=1000
Sep 14 09:48:10 ubuntubudgie audit[5573]: AVC apparmor="DENIED" operation="ptrace" profile="snap.testapp.testapp" pid=5573 comm="python3" requested_mask="read" denied_mask="read" peer="unconfined"
Sep 14 09:48:10 ubuntubudgie kernel: audit: type=1400 audit(1631627290.650:73): apparmor="DENIED" operation="ptrace" profile="snap.testapp.testapp" pid=5573 comm="python3" requested_mask="read" denied_mask="read" peer="unconfined"
ogra
September 14, 2021, 2:02pm
10
it seems to just want to read /media with the removable-media plug not connected, that should indeed not be relevant to the icon …
it seems that QSystemTrayIcon actually does not use a Tray Icon at all but uses the appindicator spec under the hood …
perhaps it would help to ship libappindicator1 in your stage packages if you don’t already (and that IIRC also needs the unity7 plug)
tmccabe
September 14, 2021, 2:42pm
11
I added libappindicator1
to my stage-packages
for both of my parts
, and I already had unity7
as one of my plugs
in testapp
under apps
in my YAML.
It made no difference regarding the icon on Ubuntu Budgie.
ogra
September 14, 2021, 2:43pm
12
well, it was worth a try at least
1 Like
ogra
September 14, 2021, 2:54pm
13
another option might be to experiment with QT_QPA_PLATFORMTHEME in an environment entry in your apps:
block … i.e. I’d try:
apps:
...:
command: ...
environment:
QT_QPA_PLATFORMTHEME: gtk3
plugs:
- ...
tmccabe
September 14, 2021, 4:00pm
14
I changed my environment as follows, and it made no difference.
apps:
testapp:
command: bin/desktop-launch python3 $SNAP/main.py &
plugs:
- desktop
- desktop-legacy
- x11
- unity7
- gsettings
environment:
DISABLE_WAYLAND: 1
QT_QPA_PLATFORMTHEME: gtk3
ogra
September 14, 2021, 4:11pm
15
tmccabe:
QT_QPA_PLATFORMTHEME
well, that seems to allow other values as well (qt5ct, gtk2, gnome, kde) i’d try them one by one , perhaps they change something in how the icon is rendered/displayed …
1 Like
tmccabe
September 15, 2021, 12:20pm
16
I couldn’t find a comprehensive list anywhere, but I was able to find a number of hypothetical values from looking at a variety of different Q-A threads like this one across the net. I tried each of these values individually and none made any difference:
QT_QPA_PLATFORMTHEME: gtk3
QT_QPA_PLATFORMTHEME: gtk2
QT_QPA_PLATFORMTHEME: qt5ct
QT_QPA_PLATFORMTHEME: gnome
QT_QPA_PLATFORMTHEME: lxqt
QT_QPA_PLATFORMTHEME: kde
ogra
September 15, 2021, 12:23pm
17
dang, that’s sad … is there any particular reason why you use a gtk desktop launcher for a Qt app btw ?
perhaps you are missing variables the qt variant of the desktop launcher would actually set …
tmccabe
September 15, 2021, 12:27pm
18
Honestly, I have no idea what I’m doing. I’ve compiled snippets from a bunch of sources and created a product that basically works, without a lot of understanding of how all the pieces fit together. I don’t know what a “desktop launcher” is. Are you saying I can get rid of the whole desktop-gtk part
in my YAML? And if I did that, might that help with the icon? Do I need to replace the desktop-gtk part
with something else?
I would probably know more about the YAML if re-snapping didn’t take so long, because I’d mess with it more to remove unnecessary stuff. But snapping takes so long that once I get something that works I stop messing with it!
ogra
September 15, 2021, 12:32pm
19
no, i’m saying there is also a qt variant of that same launcher …
remove the gtk launcher part from your snapcraft.yaml and copy in that one instead … and replace the source:
entry with:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
(and also read the usage info in the description at the top of the file)
1 Like
tmccabe
September 15, 2021, 7:17pm
20
Here’s my new YAML file, but switching from desktop-gtk
to qt5
didn’t fix the tray icon problem.
name: testapp
base: core18
version: '1.0.0'
title: 'TestApp'
summary: 'Just a test app to do tests with'
description: 'Just a test app to do tests with'
grade: stable
confinement: strict
apps:
testapp:
command: bin/desktop-launch python3 $SNAP/main.py &
plugs:
- desktop
- desktop-legacy
- x11
- unity7
- gsettings
environment:
DISABLE_WAYLAND: 1
parts:
copy-stuff:
plugin: dump
source: .
qt5:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: qt
plugin: make
make-parameters: ["FLAVOR=qt5"]
build-packages:
- qtbase5-dev
- dpkg-dev
stage-packages:
- libxkbcommon0
- ttf-ubuntu-font-family
- dmz-cursor-theme
- light-themes
- adwaita-icon-theme
- gnome-themes-standard
- shared-mime-info
- libqt5gui5
- libgdk-pixbuf2.0-0
- libqt5svg5 # for loading icon themes which are svg
- try: [appmenu-qt5] # not available on core18
- locales-all
testapp:
plugin: python
python-version: python3
source: .
python-packages:
- setproctitle
build-packages:
- coreutils
- python3-requests
stage-packages:
- coreutils
- libssl-dev
- libjpeg-dev
- libtiff-dev
- libsdl1.2-dev
- libnotify-dev
- freeglut3
- zlib1g
- libsm6
- libpulse0
- libslang2
- libsdl1.2debian
- wmctrl
- gir1.2-appindicator3-0.1
- python3-gi
- gir1.2-wnck-3.0
- x11-utils
- python3-requests
- python3-pyqt5
- libappindicator1
requirements:
- /root/project/requirements.txt