61

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 up to Ubuntu 17.04) they got removed from the dock 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;

pomsky
  • 68,507
Teivel
  • 791
  • 1
  • 6
  • 16

3 Answers3

89
  1. Create a .desktop file (or, copy if you already have one ready), say my-chrome.desktop, in your ~/.local/share/applications/ directory.
    You may add the following lines to it for a simple, bare-minimum .desktop launcher

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

    The keys are as described below

    • Name= Specific name of the application (For this particular example, I used "My Chrome" to avoid confusion with the already existing Google Chrome launcher. You can use any other name.)
    • Comment= A short description of the application
    • Exec= The command to execute in order to launch the application
    • Icon= Icon for the application (You can use an icon provided by your icon theme or an absolute path to an image file.)
  2. Click 'Activities' or 'Show Applications' and search for "My Chrome" (application name as per the Name key). It should appear.

  3. Right click on it and select 'add to favourites'.
    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 Ubuntu Dock (Add to Favorites)

pomsky
  • 68,507
  • 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
  • 2
    @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
  • 1
    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
  • The file did not show up for me in Activities – Zane Hitchcox Sep 30 '18 at 19:30
  • @ZaneHitchcox The file itself is not supposed to show up in Activities. Search by name of of the application (as per the Name= field in your .desktop file). It should show up with the icon specified (as per the Icon= field, if the specified icon file exists). – pomsky Sep 30 '18 at 19:37
  • Wow, Using this trick with searching Acitivites and then draging the icon to the dock worked for me. But what is the reason than normal way of adding to favourites doesn't work? In my case it concerned k3b dvd burner. – user2707175 Aug 02 '19 at 09:33
  • @user2707175 Sorry for the late reply, I somehow overlooked it previously. If you still have the same system, check whether the .desktop launcher for k3b contains a StartupWMClass key. – pomsky May 26 '20 at 18:48
  • I see the item in Activities but no dialog comes up when right-clicking, nor can I drag it. – Kalnode Dec 19 '22 at 17:53
  • Solved: I had to ensure the .desktop file existed in Home/.local/share/applications. Then in Activities I searched the name once more and now I see a new large icon which I can right-click and "Add to Favourites". – Kalnode Dec 19 '22 at 18:03
  • I cannot get this to work in Ubuntu 22.04, I have the postman executable and icon in the location indicated by Exec and Icon, but nothing shows up in the applications window.

    I have the .desktop file located in .local/share/applications

    [Desktop Entry] Name=Postman Comment=Postman Launcher Version=1.0 Exec=/home/skrhee/.local/share/Postman/Postman Icon=/home/skrhee/.local/share/Postman/postmanIcon Type=Application Terminal=false NoDisplay=false

    – skrhee Jan 26 '23 at 15:00
10

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.

7

For anyone having troubles, if the application is not appearing in Activities, make sure you don't have a

NoDisplay=true

line in the .desktop file for your application.

pomsky
  • 68,507
Sam Kaz
  • 201
  • 2
  • 2