Installing a "Shortcut" in the Application Menu from Python .desktop File

us flag

I would like to install a chess GUI called "PyChess". Since the repo of my distribution (20.04) doesn't offer PyChes, I downloaded a .tar.gz file, extracted it, and with a simple `./pychess` (a python file in the program's folder starting the program) I can start the GUI. The trouble is, that I would like to have my application visible in the menu (when I press super+A).

I have tried moving the pychess.desktop file into /usr/share/applications and the corresponding icon into /usr/share/icons, but to no avail: the application appears, but clicking it does nothing.

The content of the pychess.desktop file is as follows:

Comment=PyChess is a fully featured, nice looking, easy to use chess client for the Gnome desktop
GenericName=Chess Game
Exec=env UBUNTU_MENUPROXY=/home/carl/PyChess-1.0.3/pychess

As you can see, I have tried using an absolute path under Exec=, where it has once been Exec=env UBUNTU_MENUPROXY= pychess.

Thanks for taking your time.

Jacob Vlijm avatar
by flag
pychess *is* in the repos. `sudo apt install pychess` <- works here, on 20.04. Its icon is in the menu after install.
Concerto avatar
us flag
I just checked, and you're absolutely right! However, it's using the version 0.12.2-1build1 which I assume is quite antique (the newest version is 1.0.3, as far as I know). But for last resort, yes, thanks for pointing it out.
cn flag

Your command is "env". The desktop recognizes that as a valid command, and because the .desktop file is correct otherwise, will show the icon in the launcher.

All that your command does, however, is setting an environment variable.

It sets the variable UBUNTU_MENUPROXY

to: /home/carl/PyChess-1.0.3/pychess.

That may not be what you thought the command you supplied did.

Test your command first on the terminal. If it works there, it is likely (but not guaranteed) to work also from the .desktop launcher.

Concerto avatar
us flag
Thanks for your answer. The command (now modified: `Exec= env UBUNTU_MENUPROXY= opt/PyChess.../pychess`) works flawlessly in the terminal. It doesn't in the app menu. I have checked the .desktop file and there don't seem to be any mistakes. :/
vanadium avatar
cn flag
Perhaps first remove the space before "env".
Concerto avatar
us flag
Good point, but no change. Anyway, thanks for your help, I'll look further for answers!
Concerto avatar
us flag
a simple restart did the job. Thank you for your time.

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.