Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xpra does not pick up the correct menu applications / snap applications #3083

Closed
stdedos opened this issue Apr 9, 2021 · 14 comments
Closed

Comments

@stdedos
Copy link
Collaborator

stdedos commented Apr 9, 2021

I did:

sudo apt-get purge libreoffice-core libreoffice-core-nogui --autoremove
sudo snap install libreoffice

and I have even restarted since I've done these commands.

However, xpra has not picked up the snap menu options (they are in start menu)
image

and, instead, has found one "LibreOffice" option in "Office", which gives:

    214 2021-04-09 09:59:17,891 started command 'libreoffice' with pid 284573
    215 /usr/bin/libreoffice: 191: exec: /usr/lib/libreoffice/program/oosplash: not found
    216 2021-04-09 09:59:17,896 child 'LibreOffice' with pid 284573 has terminated
@totaam
Copy link
Collaborator

totaam commented Apr 10, 2021

What xpra displays in the start menu is extracted using pyxdg.
The menu loader does include a number of ugly workarounds for various pyxdg "features".
The data we retrieve is all-or-nothing by calling the Menu.parse function.

You can see the data by calling the script directly:

python3 xpra/platform/xposix/xdg_helper.py

@stdedos
Copy link
Collaborator Author

stdedos commented Apr 10, 2021

   1273     - LibreOffice
   1274       - Categories                : Office, X-Red-Hat-Base, X-SuSE-Core-Office, X-MandrivaLinux-Office-Other
   1275       - Comment                   : The office productivity suite compatible to the open and standardized ODF document format. Supported by The Document Foundation.
   1276       - Exec                      : libreoffice %U
   1277       - GenericName               : Office
   1278       - Hidden                    : False
   1279       - Icon                      : libreoffice-startcenter
   1280       - IconData                  : 926 bytes
   1281       - IconType                  : png
   1282       - MimeTypes                 : application/vnd.openofficeorg.extension, x-scheme-handler/vnd.libreoffice.cmis
   1283       - Name                      : LibreOffice
   1284       - NoDisplay                 : False
   1285       - NotShowIn                 : GNOME
   1286       - OnlyShowIn                : []
   1287       - Path                      : 
   1288       - StartupNotify             : True
   1289       - StartupWMClass            : libreoffice-startcenter
   1290       - Terminal                  : False
   1291       - TryExec                   : 
   1292       - Type                      : Application
   1293       - URL                       : 
   1294       - VersionString             : 1.0
   1295       - command                   : libreoffice %U
   1296     - LibreOffice 7.1
   1297       - Categories                : Office, X-Red-Hat-Base, X-SuSE-Core-Office, X-MandrivaLinux-Office-Other
   1298       - Comment                   : The office productivity suite compatible to the open and standardized ODF document format. Supported by The Document Foundation.
   1299       - Exec                      : env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/libreoffice_libreoffice.desktop /snap/bin/libreoffice %U
   1300       - GenericName               : Office
   1301       - Hidden                    : False
   1302       - Icon                      : /snap/libreoffice/208/usr/share/icons/hicolor/256x256/apps/libreoffice7.1-startcenter.png
   1303       - IconData                  : 3898 bytes
   1304       - IconType                  : png
   1305       - MimeTypes                 : application/vnd.openofficeorg.extension, x-scheme-handler/vnd.libreoffice.cmis
   1306       - Name                      : LibreOffice 7.1
   1307       - NoDisplay                 : False
   1308       - NotShowIn                 : []
   1309       - OnlyShowIn                : []
   1310       - Path                      : 
   1311       - StartupNotify             : True
   1312       - StartupWMClass            : libreoffice-startcenter
   1313       - Terminal                  : False
   1314       - TryExec                   : 
   1315       - Type                      : Application
   1316       - URL                       : 
   1317       - VersionString             : 1.0
   1318       - command                   : env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/libreoffice_libreoffice.desktop /snap/bin/libreoffice %U

I removed more LibreOffice packages, and the first entry (which was valid after all) disappeared.

Let's see next time what the output will be.

@stdedos
Copy link
Collaborator Author

stdedos commented Apr 15, 2021

Log out (gdk crash ...) and login fixed the situation

@totaam
Copy link
Collaborator

totaam commented Apr 30, 2021

Took another look at that menu loading code and added some tweaks above.
The menu should be reloaded automatically now on Debian / Ubuntu, even for flatpak / snap applications - even if XDG_DATA_DIRS is unset.

@stdedos
Copy link
Collaborator Author

stdedos commented May 14, 2021

... and now I managed to replicate it again 😂.

python3 xpra/platform/xposix/xdg_helper.py | grep -i libre

returns nothing; office returns only the Office subcategory

@totaam
Copy link
Collaborator

totaam commented May 14, 2021

... and now I managed to replicate it again

So... what's the cause? Is it a pyxdg bug?
Where does the libreoffice .desktop file live?
Is it somewhere found in $XDG_CONFIG_DIRS?
If loading fails, we try unsetting it.
Then we also try various values for XDG_MENU_PREFIX to try to find one that does load.

@stdedos
Copy link
Collaborator Author

stdedos commented May 19, 2021

Where does the libreoffice .desktop file live?

/snap/libreoffice/21[38]
/usr/share/app-install/desktop # idk if that's from snaps, but the `Exec=` directive works when manually called
/var/lib/snapd/desktop/applications

Is it somewhere found in $XDG_CONFIG_DIRS?

No such $XDG_CONFIG_DIRS in my bash env

XDG_MENU_PREFIX

No such XDG_MENU_PREFIX either

I have also lost the File menu, if that's somehow related ...

@totaam
Copy link
Collaborator

totaam commented May 19, 2021

XDG_CONFIG_DIRS, as per basedir spec:
If $XDG_CONFIG_DIRS is either not set or empty, a value equal to /etc/xdg should be used.
FYI: If we can't load the menus with the current value, we try unsetting it. (not applicable to your setup)

XDG_MENU_PREFIX, as per menu spec:
$XDG_CONFIG_DIRS/menus/${XDG_MENU_PREFIX}applications.menu This file contains the XML definition of the main application menu layout
We try the following prefix values: unchanged, empty, gnome- and kde-.

@stdedos
Copy link
Collaborator Author

stdedos commented May 19, 2021

u@h:/etc/xdg/menus$ locate '*.menu'
Running:
locate '*.menu'
/etc/xdg/menus/gnome-applications.menu
/etc/xdg/menus/unity-lens-applications.menu
/etc/xdg/menus/unitycc.menu
/usr/share/app-install/desktop/applications.menu
/usr/share/menu/google-chrome.menu
/usr/share/menu/vivaldi.menu
/home/u/.config/menus/applications-merged/user-chrome-apps.menu
/home/u/.config/menus/applications-merged/xdg-desktop-menu-dummy.menu
u@h:/etc/xdg/menus$ locate '*.menu' | xargs grep -Trin libre
Running:
locate '*.menu'
u@h:/etc/xdg/menus$ locate '*.menu' | xargs grep -Trin termin
Running:
locate '*.menu'
/etc/xdg/menus/gnome-applications.menu:    47:	      <Filename>org.gnome.Terminal.desktop</Filename>
/etc/xdg/menus/gnome-applications.menu:   302:	      <Filename>org.gnome.Terminal.desktop</Filename>
/etc/xdg/menus/gnome-applications.menu:   433:	      <Filename>org.gnome.Terminal.desktop</Filename>
u@h:/etc/xdg/menus$ 

I guess I need to dig where on earth are the .menu files for the snap applications 😠

@stdedos
Copy link
Collaborator Author

stdedos commented May 26, 2021

Unfortunately, neither my Bionic laptop (one who gets more regular maintenance, reboots etc) seems to have any .menu files listing LibreOffice.

Instead, it seems that there are a lot of files in
/var/lib/snapd/desktop/applications/ (e.g. /var/lib/snapd/desktop/applications/libreoffice_calc.desktop)

Maybe these are the ones loaded somehow? 😕

@totaam
Copy link
Collaborator

totaam commented May 27, 2021

Logging in to a desktop session on Ubuntu 18.04, I see:

XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop

This comes from /etc/profile.d/apps-bin-path.sh

Adding --source=/etc/profile should fix this. (at least the value of $XDG_DATA_DIRS)
BUT there may be other issues with loading the full profile script, it may interfere or cause bugs / crashes. So we may want to source the snap script specifically.

@stdedos does that fix things?

@totaam totaam reopened this May 27, 2021
@stdedos
Copy link
Collaborator Author

stdedos commented May 27, 2021

I laser-focused on the /etc/profile.d/apps-bin-path.sh; and that fixes things.

Apart from

2021-05-27 09:22:44,629 Error: cannot find file '%s' to source

😛

(no adjacent errors)

totaam added a commit that referenced this issue May 27, 2021
@totaam
Copy link
Collaborator

totaam commented May 27, 2021

Let's see how it goes in the beta channel with /etc/profile

@totaam
Copy link
Collaborator

totaam commented Feb 16, 2023

On the subject of snap: #3740

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants