81

Let's say I changed/added some myapp.desktop file at ~/.local/share/applications/. For some time Ubuntu Unity will still show me old applications shortcuts at Unity lens under Ubuntu button. It will take some time (or just a one restart) to get applications list updated there.

How I can force Unity reload ~/.local/share/applications and reflect shortcuts correctly in lens?

7
  • Have you tried unity --reset? Nov 12, 2013 at 15:36
  • Correction. It should just be unity. Press alt+F2 and type in the command. Nov 12, 2013 at 15:41
  • Yes. It didn't help. It still shows old application name after unity or unity --reset (which was before I modified myapp.desktop file).
    – vladimir
    Nov 12, 2013 at 16:55
  • Odd, it seems to be working fine when I do the exact same thing you're doing. Have made sure the .desktop file is executable? Nov 12, 2013 at 17:26
  • 1
    Analogous question for newer Ubuntus: unix.stackexchange.com/questions/12118/….
    – wrwrwr
    Aug 2, 2020 at 16:34

7 Answers 7

91

A little late, but i stumbled upon this thread before finding a solution, atleast to my problem, googling something related, nearly giving up.

As per this guide help.ubuntu.com, don't just edit or create your .desktop files in /usr/local/share/applications or ~/.local/share/applications. Instead, create the file somewhere else and use

desktop-file-install <your_file.desktop>

to add the file.

E.g. you create ~/myapp.desktop and do

desktop-file-install --dir=$HOME/.local/share/applications ~/myapp.desktop

Existing files of the same name will be overwritten and unity updated, you can use --delete-original if the source is not needed anymore, or

sudo desktop-file-install ~/myapp.desktop

to install it for all users.

8
  • +1 this works. A rough edit script using this recipe is at gist.github.com/hilbix/f468fcbb15c3f68670d8
    – Tino
    May 25, 2014 at 9:51
  • 5
    just putting a copy of the .desktop file in ~/.local/share/applications worked for me-
    – chrismarx
    Mar 18, 2015 at 14:01
  • I usually manually edit the file and add it to .local/share/applications/. Tried using the command with --delete-original and I got a warning: warning: key "Keywords[uk]" is a list and does not have a semicolon as trailing character, fixing. The result was the source file deleted and nothing copied to the target directory. Evil OS... basically nuked my file and I had to create a new one from scratch.
    – Daniel
    Mar 9, 2017 at 11:00
  • 4
    I still get the issue OP noticed even when doing this.
    – JAB
    Mar 28, 2017 at 16:22
  • 2
    I also still get the issue OP noticed even when doing this (and even after restarting) (Ubuntu 16.04). Jul 22, 2017 at 18:05
25

sudo update-desktop-database will refresh the .desktop database.

5
  • 2
    This didn't work for me. Running Ubuntu 16.04. I still don't see on the launcher icon the changes made in the .desktop file.
    – RichArt
    Nov 24, 2017 at 22:02
  • 4
    This command only updates MIME type databases. It does not update any other changes. See: manpages.ubuntu.com/manpages/zesty/man1/…
    – hife
    Dec 5, 2017 at 15:47
  • It worked for me
    – aless80
    Oct 25, 2018 at 5:15
  • works for me with sudo
    – Mahoor13
    Feb 10, 2019 at 9:10
  • 1
    Worked like a charm on Ubuntu 22.10
    – Martin
    Nov 10, 2022 at 9:39
18

The way to do this is to run the command

killall unity-scope-home

after opening the dash the process is started automatically again.

The correct icons are then displayed...

5
  • 1
    Does not work at my side. I removed a .desktop file and it still shows up in compiz launch bar.
    – Tino
    May 25, 2014 at 8:35
  • Well, stuck with BUG 1287663 the solution was to use gsettings set followed by ( unity --replace & )
    – Tino
    May 25, 2014 at 10:24
  • I don't know what you mean with compiz launch bar?! I thought you were talking about the dash?
    – wa4557
    May 26, 2014 at 11:19
  • Works fine for me, Applications are listed again Nov 20, 2014 at 15:14
  • 2
    Any alternatives in 15.10? I'm getting unity-scope-home: no process found
    – ardila
    Nov 30, 2015 at 20:17
8

According with this answer (and you can find many others in the same sense), unfortunately there seems to be no command to let the unity-applications-daemon refresh its application cache. But I can confirm that unity will automatically detect any changes with .desktop files in ~/.local/share/applications. If these changes are not immediately available, try logging out and in again to refresh it.

3
  • 3
    Yeah, it will automatically detect .... in an hour ...
    – vladimir
    Nov 12, 2013 at 18:28
  • @vladimir As I said, if you want the changes immediately available, try logging out and in again to refresh it. Nov 12, 2013 at 18:29
  • 3
    I fully got your answer and probably will accept it. You understand downsides of logging off - all opened apps closed. It's not a solution, it's a workaround and not a user friendly one. Are you developer by any chance? If yes, could you please point me to the daemon sources? I guess this is it: unity-lens-applications daemon.vala
    – vladimir
    Nov 12, 2013 at 21:28
5

This answer does not involve a desktop restart.


Though quite late, there's a utility command to update the desktop database cache named update-desktop-database.

Updating stuffs added in $HOME/.local/share/applications/, use:

>> update-desktop-database

Updating stuffs addded in global ones, like /usr/share/ubuntu/applications, /usr/share/gnome/applications, /usr/share/applications, etc., use:

>> sudo update-desktop-database
1
  • 1
    This works for me.
    – Honghe.Wu
    Feb 25, 2019 at 11:05
0

Some applications might stop working properly after this command. Chrome, for example, became totally black.

unity --replace
1
  • Could you clarify your warning(?)?
    – Zanna
    Apr 3, 2017 at 16:28
0

I had a similar issue, fixed when restart. I use ubuntu 16.04

I usually create .desktop files in /usr/share/applications/ if I want to share the desktop files with other users and ~/.local/share/applications if for only one user. And I usually restart.

You must log in to answer this question.

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