Regarding the icons
folder
The only program that has icons in ~/.local/share/icons
is Wine, so no, a default install shouldn't create the folder.
Most installed programs place their icons in /usr/share/icons
, where all users can access them.
Regarding the .desktop
file
I went ahead and created it, and the rest of the folders mentioned in the answer, ~/.local/share/icons/hicolor/16x16/
etc.
The icon has to be placed in a folder called ~/.local/share/icons/hicolor/16x16/apps/
.
What happens if you lock/unlock an application to/from the launcher
Not sure if this answer is deep enough "under the hood", but this is what happens:
You can get the current content of the Unity Launcher by the command:
gsettings get com.canonical.Unity.Launcher favorites
It will produce a list, looking like:
['application://extras-qlequicklisteditor.desktop', 'application://gedit.desktop', 'application://gnome-terminal.desktop', 'application://nautilus.desktop', 'application://firefox.desktop', 'application://thunderbird.desktop', 'application://gnome-screenshot.desktop', 'application://dconf-editor.desktop', 'application://virtualbox.desktop', 'application://gnome-tweak-tool.desktop', 'unity://running-apps', 'unity://devices', 'unity://expo-icon']
The mentions in the list are obviously based on the names of the corresponding .desktop
files.
Now when you run a GUI application, when you right- click on its icon in the launcher and choose Lock to Launcher, The currently chosen item is added to the list, while Unlock from Launcher will remove the item from the list.
Editing the Unity Launcher programmatically
Re- reading your (first) comment below your question: You can, as mentioned, get the current Launcher items by the command:
gsettings get com.canonical.Unity.Launcher favorites
and set a possible altered list by the command:
gsettings set com.canonical.Unity.Launcher favorites "[item1, item2, etc]"
You can then of course edit the Unity Launcher's content programmatically, as is done here.
If the application has no .desktop file
If You run a GUI application without an existing .desktop
file, Unity creates a basic one locally (in ~/.local/share/applications
), named after the executable (application.desktop
). In the Exec=
line, you will find the command you ran, to call the application.
If you would look into a .desktop
file, created this way, it includes the line:
X-UnityGenerated=true
Note
As mentioned by @muru (thanks!), in a few (exceptional, as it seems) situations, Unity does not succeed to create a "missing" .desktop
file of an executable. The only example I could find however was in case of Tkinter windows, which are owned by pid 0
in the output of wmctrl -lp
.
Best Answer
Desktop files contain a command to open an application. It is not much more than a textfile, with the extension ".desktop". Although you can store these files anywhere, and run it as a standalone link to an application (that is: if you make it executable), the default locations are:
(globally) or
(locally).
What you need to do is paste the text in your post into an empty textfile (open gedit), and change the line:
What do you need to change?
Explanation of the sections of the line:
This means: what comes after this will be executed if the desktop file is invoked. That is actually what would make the application start if you would run it in a terminal.
this is telling the shell to go into the directory where the application is located (the backslash in
/Program\ Files
is to escape the space in the name of theProgram Files
folder, telling the shell not to stop at the space).You should replace
USER
with your own username, replaceFOOBAR_FOLDER
with the name of the application folder. If you don't know, open your home directory, press ctrl+h to make the.wine
folder visible (if it isn't already), and browse into the directory~/.wine/drive_c/Program Files
to see the name of your application folder.This tells the shell to run
foobar.exe
with Wine. Replace foobar.exe with the actualapplication_name.exe
.Finally, your
Exec=
line should look something like (if RedNotebook is your application for example):Then, after you have changed the line
Name=Foobar
into a more appropriate name, save the file as (for example)rednotebook.desktop
If you want to use the file as a starter on your Desktop, save it there as
renotebook.desktop
and make it executable. If you want to run it from Dash, move it into~/.local/share/applications
. After log out and back in, it will be available in Dash. You can lock it to the launcher then.