76

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 '13 at 15:36
  • Correction. It should just be unity. Press alt+F2 and type in the command. Nov 12 '13 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 '13 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 '13 at 17:26
  • 1
    Analogous question for newer Ubuntus: unix.stackexchange.com/questions/12118/….
    – wrwrwr
    Aug 2 '20 at 16:34
87

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 '14 at 9:51
  • 5
    just putting a copy of the .desktop file in ~/.local/share/applications worked for me-
    – chrismarx
    Mar 18 '15 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 '17 at 11:00
  • 4
    I still get the issue OP noticed even when doing this.
    – JAB
    Mar 28 '17 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 '17 at 18:05
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 '14 at 8:35
  • Well, stuck with BUG 1287663 the solution was to use gsettings set followed by ( unity --replace & )
    – Tino
    May 25 '14 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 '14 at 11:19
  • Works fine for me, Applications are listed again Nov 20 '14 at 15:14
  • 1
    Any alternatives in 15.10? I'm getting unity-scope-home: no process found
    – ardila
    Nov 30 '15 at 20:17
16

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

4
  • 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 '17 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 '17 at 15:47
  • It worked for me
    – aless80
    Oct 25 '18 at 5:15
  • works for me with sudo
    – Mahoor13
    Feb 10 '19 at 9:10
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 '13 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 '13 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 '13 at 21:28
4

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
  • This works for me.
    – Honghe.Wu
    Feb 25 '19 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 '17 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.

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.