16

I am learning the Ubuntu SDK, and I have make an new HTML5 Touch UI project with Qt Creator.

The project folder has an .desktop file. I then added an launcher.png to my project's folder.

Here is my .desktop file:

[Desktop Entry]
Name=myapp
StartupNotify=true
Icon=/usr/share/myapp/launcher.png
MimeType=text/plain;
NoDisplay=true
Comment=something...
Exec=/usr/bin/qmlscene $@ /usr/share/myapp/diaspora-webclient.qml
Terminal=false
Type=Application
X-Ubuntu-Touch=true

Now I press Ctrl+R to run the app with qmlscene. The app runs, but launcher.png is not displayed as the app's icon in the Unity Launcher.

Do I need to run an command to update the changes? Or do I need to move the launcher.png to /usr/share/myapp/launcher.png via in-app-code?

5
  • 1
    You need to set the real path to the image. For testing purposes you can set it to be the path inside your development structure. Notice that moving the file to /usr/share would require you to type your password each time. Another alternative is to simply put a copy of the icon in ~/.icons.
    – edwin
    Aug 16, 2013 at 0:43
  • 1
    Make sure that you have permissions to read the file.
    – Mitch
    Aug 16, 2013 at 6:24
  • Ok... so there is not any standard path where icons should be placed?
    – Voidcode
    Aug 16, 2013 at 19:05
  • Already told you, you can put them on ~/.icons (for testing purposes).
    – edwin
    Aug 23, 2013 at 3:35
  • 1
    Yes but only for testing purposes,.. right..
    – Voidcode
    Aug 27, 2013 at 1:56

2 Answers 2

33

There are two things wrong with how you're doing things.

Fist of all, .desktop files are intended for installed apps, not for running via Ctrl+R. To install your app, you need to package it and install the package. You can find more details about packaging your app and publishing it in the Click App Store here.

Second of all, the paths you have in the .desktop should be local files, not absolute paths. Here is an example of a .desktop file:

[Desktop Entry]
Name=Tasks
Comment=Your tasks, every device, everywhere.
Exec=qmlscene $@ ubuntu-tasks.qml
Icon=ubuntu-tasks.png
Terminal=false
Type=Application
X-Ubuntu-Touch=true

A couple of things to note:

  • The Exec line should be in the format of qmlscene $@ <file.qml>, with just the name of your main QML file, no directory information.

  • The Icon line should be in the form of Icon=<icon.png>, with just the file name (including the extension), no directory information.

Now the information I've provided above is for running your app on an Ubuntu Touch device by packaging it in a Click package. Click packages are intended for Ubuntu Touch and currently don't integrate with the Unity desktop. So, if you want to be able to run your app from the Dash/Launcher and also see its icon, you will need to do two things:

  1. Copy your .desktop file to ~/.local/share/applications and use an absolute path to your icon instead of just the file name, as you would when packaging the app.

  2. Copy your icon to ~/.icons

3
  • 2
    Great! It also seems, that the *.png-file is supposed to have the same width as its height is and not exceed 512px on any side (at least for me a regular png-image was not resized properly as a icon; downsizing and extending it to be quadratic (512x512px) helped).
    – Igor
    Nov 4, 2019 at 6:47
  • 4
    To make it works on Ubuntu 20.04, I've to copy the .png file into the ~/.local/share/icons/hicolor/256x256/apps folder instead of the pointed out here. Apr 25, 2022 at 12:42
  • 1
    I could fix the missing icon problem by creating the folder ~/.icons and copying there my icon's PNG file. May 30, 2023 at 15:00
0

Desktop Version: For me in Ubuntu 20.04 Desktop the icon of Squeezeplay was not showing up, neither in the search window, nor in the gnome3 side dock panel.

The solution above worked from @iBelieve for me showing up an icon in the search dialog, but not in the gnome side panel.

Adding the StartupWMClass=jive (found out clicking the opened application using xprop WM_CLASS in the cli)to the desktop file from the answer here completed the Mission, now I can see everywhere (search dialog, pressing "Windows" key and gnome dock side panel) the provided icon file (png file format, max size 512x512, I choose 256x256)! The desktop file was generated like:
$ vim ~/.local/applications/squeezeplay.desktop:

[Desktop Entry]
Name=Squeezeplay
StartupNotify=true
MimeType=text/plain;
Comment=https://sourceforge.net/projects/lmsclients/files/squeezeplay/linux/ The Linux version of Squeezelite-X (similar) working with LMS
Exec=/opt/squeezeplay/bin/squeezeplay.sh
Icon=squeezeplay-icon2-256x256.png
Terminal=false
Type=Application
StartupNotify=true
StartupWMClass=jive
Categories=Utility;Radio;

Like explained the icon was stored in ~/.icons directory with the name given in Icon=! Thanks to @iBelieve and @Puspam!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .