How to create a .desktop file to show up among my apps?

I followed these instructions to create a .desktop file and saved it in .local/applications. This is what it looks like:

[Desktop Entry]
Type=Application
Name=MACS
Icon=$HOME/src/maxtouch-external/MAXNewOSX/Images.xcassets/AppIcon.appiconset/AppIcon256.png
Exec=$HOME/src/maxtouch-external/build/MACS

It doesn’t show up among my apps however. I tried copying it to the Desktop folder, but it doesn’t show up on the desktop either. In fact, no file in the Desktop folder shows up on my desktop.

I’m on fedora workstation with a gnome desktop.

So, how to create an application entry in the nine dot apps thing?

It should be ~/.local/share/applications, not .local/applications. You may need to logout and login again.

4 Likes

There is now a small delay but noticable delay when I login. I assume it finds my macs.desktop file but can’t parse it correctly. I’ve already tried with smaller icon sizes.

Is there a way to see the output for when macs.desktop is parsed? Maybe there is an error.

And there is still no icon among my apps.

I’ve just come across desktop-file-validate, which complains about the $HOME in my file:

$ desktop-file-validate macs.desktop 
macs.desktop: error: value "$HOME/src/maxtouch-external/MAXNewOSX/Images.xcassets/AppIcon.appiconset/AppIcon64.png" for key "Icon" in group "Desktop Entry" looks like a relative path, instead of being an absolute path to an icon or an icon name
macs.desktop: error: value "$HOME/src/maxtouch-external/build/MACS" for key "Exec" in group "Desktop Entry" contains a reserved character '$' outside of a quote

Is there now a different way to refer to the home directory? Or do I need to have absolute path’s in there?

Anyway, with absolute path’s it works!

In a .desktop file you should always use absolute paths.

I didn’t find a way for Icon, but Exec’s can be done with bash to pull off references.


With my notes for 2004Scape, I do this for the desktop launcher:

[Desktop Entry]
Name=2004Scape
Categories=Game;
Exec='/bin/bash' -c "gio open 'http://localhost:8888'"
Type=Application
StartupNotify=false
Icon=/home/CHANGEME/Projects/2004Scape-Server/src/public/favicon.ico
Actions=Server;Update;Saves;Notes;

[Desktop Action Server]
Exec='/bin/bash' -c "konsole -p tabtitle='2004Scape localhost Server' -e ~/'Projects/2004Scape-Server/localhost-server-start.sh'"
Name=Launch Local Server
...

The Exec for the Server action references ~ through bash. I copy/paste stuff from my notes and for Icon I use sed to change the CHANGEME to the name of the user that runs the command:

sed -i 's/'CHANGEME'/'$USER'/g' ~/'.local/share/applications/2004Scape-localhost.desktop'

And this refreshes the desktop launcher list (convenient vs logging out/back in but might be inconsistent on GNOME):

update-desktop-database --quiet ~/'.local/share/applications'

Alternatively for Icon you can put the icon file in ~/.local/share/icons/hicolor/ and then just reference the file name; so something like:

[Desktop Entry]
Name=World of Warcraft 3.3.5
Categories=Game;
Exec='/bin/bash' -c "cd ~/'.wine/World of Warcraft 3.3.5/drive_c/Program Files/World of Warcraft 3.3.5a.12340'*'/' && wine 'Wow.exe' -d3d9ex"
Type=Application
StartupNotify=true
StartupWMClass=wow.exe
Icon=WBE5_Wow.0

Will use the icon file:

~/.local/share/icons/hicolor/48x48/apps/WBE5_Wow.0.png
3 Likes