SOLVED | .desktop file is ignored / no menue entry appears in Mint Menu

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon
Post Reply
dimic
Level 1
Level 1
Posts: 11
Joined: Fri Jan 15, 2016 7:40 pm

SOLVED | .desktop file is ignored / no menue entry appears in Mint Menu

Post by dimic » Tue Nov 06, 2018 11:39 pm

SYSTEM
Linux Mint 18.3 Sylvia x64 Cinnamon
Kernel 4.15.0-36-generic
Ubuntu 16.04.1
Cinnamon 3.6.7

PROBLEM .desktop file is ignored / no menu entry appears in Mint Menu

DETAILS
I want to add an entry for a game to the Mint Menu during the installation of the app.
After the game has been installed to /usr/games and /usr/share/games, I want to set up the menu entry in the postinstall script.

I tried:
1. Place a .desktop file in directory /usr/share/applications
cp /usr/share/games/MyGame/pkg/MyGame.desktop /usr/share/applications

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=MyGame
Comment=Some description
Exec=/usr/games/MyGame
Icon=/usr/share/games/MyGame/pkg/mygame.png
Terminal=true
Categories=Game;
Result: Menue entry does NOT appear in Mint Menu

2. Install the .desktop file using command desktop-file-install
desktop-file-install --dir=/usr/share/applications /usr/share/games/MyGame/pkg/MyGame.desktop
Result:
a) .desktop file is installed in /usr/share/applications correctly
b) an additional line is added to the .desktop file:
"X-Desktop-File-Install-Version=0.22"
c) Menu entry does NOT appear in Mint Menu

3. Check syntax of .desktop file using desktop-file-validate
desktop-file-validate /usr/share/applications/MyGame.desktop
Result: reports no errors, still the desktop file is ignored

4. Update Desktop database
sudo /usr/bin/update-desktop-database
Result: still no menu entry

5. Log out and log in, reboot
Result: still no menu entry

REMARKS
I saw a lot of reports about similar problems in different Ubuntu/Mint/Cinnamon forums, but found no solution.
But some programmers have successfully implemented menu entries into their packages.
Has someone got a hint for me?
Last edited by dimic on Sat Nov 24, 2018 6:42 pm, edited 1 time in total.

User avatar
smurphos
Level 8
Level 8
Posts: 2233
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: .desktop file is ignored / no menue entry appears in Mint Menue

Post by smurphos » Wed Nov 07, 2018 1:41 am

First try right click on the menu, configure, navigate to the menu tab and select menu-editor. Select Restore System Configuration - this should force the menu to pick up your new .desktop file. if it doesn't work check the permissions of the files in /usr/games/MyGame/ and /usr/share/games/MyGame/. Are they Other readable and executable. They should be root owned. Also try the desktop file in ~/.local/share/applications

If that still doesn't work in menu-editor you can manually create an entry with the New Item dialog.

Fill in the fields requested - e.g MyGame, /usr/games/MyGame and an optional comment. Click on the icon place-holder and manually select your icon. Save,

This will create the corresponding desktop file in ~/.local/share/applications

dimic
Level 1
Level 1
Posts: 11
Joined: Fri Jan 15, 2016 7:40 pm

Re: .desktop file is ignored / no menue entry appears in Mint Menu

Post by dimic » Wed Nov 07, 2018 1:15 pm

Thanks for your quick reply!

Unfortunately, the suggested steps did not help to create a menue entry automatically.
The .desktop file still is not recognized.

For my own computer, setting up an entry with the Menue editor works fine.
But I look for an automated way within the installation of my game.

I found some new documents by the Open Desktop Foundation and the Cinnamon project, I keep on trying...

Greetings, Dieter

kreemoweet
Level 1
Level 1
Posts: 40
Joined: Sat Feb 20, 2016 12:08 am

Re: .desktop file is ignored / no menue entry appears in Mint Menu

Post by kreemoweet » Wed Nov 07, 2018 2:23 pm

"Terminal=true". I believe this is wrong. Terminal applications do not appear in the menu.

User avatar
smurphos
Level 8
Level 8
Posts: 2233
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: .desktop file is ignored / no menue entry appears in Mint Menu

Post by smurphos » Wed Nov 07, 2018 3:26 pm

Ah i see - I misunderstood that you were trying to create an install script. (read I read your post too quickly :roll: :wink: ) I think the command you might be looking for in both your install and uninstall scripts to update the menu after adding / removing the .desktop file is xdg-desktop-menu.

See man xdg-desktop-menu or https://linux.die.net/man/1/xdg-desktop-menu

gm10
Level 13
Level 13
Posts: 4595
Joined: Thu Jun 21, 2018 5:11 pm

Re: .desktop file is ignored / no menue entry appears in Mint Menu

Post by gm10 » Wed Nov 07, 2018 3:38 pm

dimic wrote:
Tue Nov 06, 2018 11:39 pm
Linux Mint 18.3 Sylvia x64 Cinnamon

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=MyGame
Comment=Some description
Exec=/usr/games/MyGame
Icon=/usr/share/games/MyGame/pkg/mygame.png
Terminal=true
Categories=Game;
Result: Menue entry does NOT appear in Mint Menu
I don't see a problem with the file, my only idea would be to check file permissions.

Just for reference, I did nano ~/.local/share/applications/test.desktop, copy & pasted your code block, reloaded the menu and the entry showed up without a problem on LM19 MATE. Can't comment on Cinnamon.

dimic
Level 1
Level 1
Posts: 11
Joined: Fri Jan 15, 2016 7:40 pm

Update .desktop file is ignored / no menue entry appears in Mint Menu

Post by dimic » Sat Nov 24, 2018 6:40 pm

Thanks for your hints!

permissions of .desktop file
I used the same permissions like some examples in /usr/share/applications, this was not the solution

xdg-desktop-menu command
seems to do the same like commands desktop-file-install and update-desktop-database,
didn't help in my case

terminal programs won't show up in the menue
Menue entries for terminal programs work fine, only the automatic detection of the desktop file did not work.
In my case, a shell script is executed that sets some gnome-terminal settings and starts a Perl script in a gnome terminal.
(Yes, i am an old Unix nerd, i have programmed a terminal game...)
Once the system has detected the desktop file, the menue entry works fine.

dpkg trigger
one solution really helped:
I have build a dpkg package of my game and installed it using dpkg -i mygame.
The message
Processing triggers for desktop-file-utils (0.22+linuxmint1) ...
occured and -voilá- there it was: the menue entry "MyGame" in category "Games".
So whatever the trigger of package desktop-file-utils does, it worked fine.
So I say bye-bye to my solution with a self-extracting tar archive and use a Debian package now.

This is magic...
Since I have installed a Debian package, now the automatic detection of desktop files in /usr/share/applications
also works for files that have been placed there manually.
Hm, sometimes it is annoying when something works, but you don't know why.

At least, my problem is solved and I know how to make a deb package...

User avatar
smurphos
Level 8
Level 8
Posts: 2233
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Update .desktop file is ignored / no menue entry appears in Mint Menu

Post by smurphos » Sat Nov 24, 2018 11:46 pm

dimic wrote:
Sat Nov 24, 2018 6:40 pm
Hm, sometimes it is annoying when something works, but you don't know why.
apt show desktop-file-utils gives a hint. It provides a couple of commands that I guess may be doing the magic on a deb install - desktop-file-install and update-desktop-database

Post Reply

Return to “Cinnamon”