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

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
dimic
Level 1
Level 1
Posts: 18
Joined: Fri Jan 15, 2016 7:40 pm

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

Post by dimic »

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 LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

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

Post by smurphos »

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
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
dimic
Level 1
Level 1
Posts: 18
Joined: Fri Jan 15, 2016 7:40 pm

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

Post by dimic »

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 2
Level 2
Posts: 51
Joined: Sat Feb 20, 2016 12:08 am

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

Post by kreemoweet »

"Terminal=true". I believe this is wrong. Terminal applications do not appear in the menu.
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

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

Post by smurphos »

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
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
gm10

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

Post by gm10 »

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: 18
Joined: Fri Jan 15, 2016 7:40 pm

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

Post by dimic »

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 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

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

Post by smurphos »

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
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
Locked

Return to “Cinnamon”