47

Problem:

I have made .desktop files for Ubuntu 16.04 to access my Google Chrome profiles, but once I upgraded to Ubuntu 17.10 (it worked on Ubuntu 17.04) they got removed and I can't pin them back.

Sample File

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=google-chrome
Name[en_US]=Google Chrome
Exec=google-chrome --profile-directory=Default
Comment[en_US]=Chrome
Name=Google Chrome
Comment=Chrome Browser
Icon=google-chrome
Categories=Browser;Internet;
  • 1
    If you can see them in the gnome-shell overview then you can DnD to the dock (just not at the end). If not then mark the .desktop as executable, d. click on, set as trusted. Once running it should show in dock & you can pin – doug Oct 22 '17 at 1:00
  • @doug But wouldn't that kill the Exec=google-chrome --profile-directory=Default? – Teivel Oct 22 '17 at 1:14
  • I don't know what you mean. Do you know what I mean by "mark as executable" i.e, r. click on the .desktop .> properties > Permissions > obvious – doug Oct 22 '17 at 1:32
  • 1
    @doug it passes arguments to the program before launching, in this case, the profile, if I was to pin it, only the application would launch, not the right profile (ie. guest, personal, etc) – Teivel Oct 22 '17 at 1:54
70
  1. Create a .desktop file in ~/.local/share/applications.
  2. Add the following lines in it

    [Desktop Entry]
    Comment=Chrome my profile
    Terminal=false
    Name=My Chrome
    Exec=google-chrome --profile-directory=Default
    Type=Application
    Icon=google-chrome
    

    (I'm naming it "My Chrome" to avoid confusion with the already existing Google Chrome launcher. You can use any other name.)

  3. Click Activities or Show Applications and search for "My Chrome". It should appear.

  4. Right click on it and mark as favourite.

    If right clicking on application icon in dock doesn't show "Add to favourites" option, search for the application in Activities screen, and then drag it across to the dock (suggested by Legolas).

If nothing works, see this Q&A: Cannot add custom launcher to Dock (*Add to Favorites*)

  • Is a restart or re-login needed? For me this does not even make the thing show up in the "Activities" dashboard. – Zelphir Kaltstahl Jan 16 '18 at 10:29
  • 1
    @Zelphir Should not be required, but try anyway. If still doesn't work, see this. – pomsky Jan 16 '18 at 10:35
  • 1
    When you put in a path, you can't use ~. Use the full path. When I had ~, nothing showed up. Moving to a full path worked fine. – Virmundi May 28 '18 at 17:47
  • Yes, of course, you can't put ~ in the .desktop file, you'll have to put the full path (there is no ~ in the content of the sample .desktop file though). – pomsky May 28 '18 at 18:01
  • Thanks a lot! After 2 hours of browsing, this answer solved my problem! – sh4dowb Jun 12 '18 at 11:32
5

I had the same problem with Firefox Nightly. The following configuration works for me in ~/.local/share/applications/firefox-nightly.desktop:

[Desktop Entry]
Type=Application
Name=Firefox Nightly
#
# WARNING: Remember to fix the path in Icon and Exec
#
Icon=/path/to/firefox-nightly/browser/icons/mozicon128.png
Exec=/path/to/firefox-nightly/firefox %u
Terminal=false
StartupWMClass=Nightly

Without StartupWMClass, the running application is not recognized and the icon is displayed twice on the dock.

  • 2
    Multiple icons of the same application (and also fallback to a default "blank" icon after failing to show specified icon in the .desktop file) sounds like a separate issue. I think it would be better if you ask a new question and add an answer yourself. There's already this one. – pomsky Nov 7 '17 at 15:37
  • 1
    @pomsky I posted it here because I had the same problem: it was not possible to mark the app as favourite in the context menu. Dragging it from the activities screen did almost work: the icon was pinned but, clicking it, another icon was shown. By adding StartupWMClass to your config, it finally worked. Sorry for the confusion. Maybe I should answer to this one? – Marcello Nuccio Nov 7 '17 at 17:29
  • 1
    Already I have posted an answer (StartupWMClass trick) there a week ago. If your answer is significantly different you're most welcome to post a new answer. But the thing that question is a bit misleading, there OP has the issue in only Wayland, not Xorg. So I think it's better if you could post an new question and answer it yourself. I didn't see a new questions with multiple icons issue recently, only saw a comment. – pomsky Nov 7 '17 at 17:34
3

For anyone having troubles, if the application is not appearing in Activities, make sure you don't have "NoDisplay=true" in the .desktop file for your application.

-1

I can confirm the above mostly works on Ubuntu 18.04.

Note that putting the .desktop file in ~/.local/share/applications has no visual effect.

It does not put an entry on your desktop!

However, it does add the application to your list of applications and then allows it to be added to favorites (sometimes).

So, why does the file have .desktop as an extension when it has nothing to do with the desktop?

If you think this is muddled thinking by developers, you will not be alone.

This file:

[Desktop Entry]
Version=1.0
Type=Application
Name=PhpStorm
Icon=/usr/local/PhpStorm-183.5153.36/bin/phpstorm.svg
Exec="/usr/local/PhpStorm-183.5153.36/bin/phpstorm.sh" %f
Comment=Lightning-smart PHP IDE
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-phpstorm

Placed in ~/Desktop with the name jetbrains-phpstorm.desktop does not show an icon on the desktop.

However, if it is named PhpStorm.desktop it does put an icon on the desktop.

The exact same file placed in ~/.local/share/applications with the name jetbrains-phpstorm.desktop does 2 things:

  1. Shows PhpStorm in Show applications
  2. Allows you to Add to favorites

And in ~/.local/share/applications, it doesn't matter what you call the file: jetbrains-phpstorm.desktop works the same as PhpStorm.desktop

When I said "sometimes", here's a file that works in ~/Desktop and when placed in ~/.local/share/applications allows the application to appear in Show applications but does not allow you to Add to favorites:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=gnome-panel-launcher
Name[en_US]=Create Launcher
Exec=bash -c 'gnome-desktop-item-edit --create-new ~/Desktop'
Name=Create Shortcut
Icon=gnome-panel-launcher

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.