Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write a script to setup my desktop environment after a fresh install. One thing I can't figure out is how to pin/unpin items to the Unity Launcher from a bash script. Any ideas?

share|improve this question
Have you considered copying the configuration files? – richard Jul 18 '12 at 15:37
Don't know what or where they are? – HDave Jul 18 '12 at 15:47
They are in your home directory and start with a dot, so are hidden. Type ls -dF .* I don't know which you need, there are files for just about every application you run. – richard Jul 18 '12 at 16:02
The list of items on the launcher is not in a simple configuration file, or a directory full of files itself. – dobey Jul 18 '12 at 16:13
It is easy to add launchers but the thing is that in every solution available online, you have to do an ugly restart... – hakermania Aug 3 '12 at 23:02
up vote 6 down vote accepted

Use gsettings:

gsettings get com.canonical.Unity.Launcher favorites

Gives you a list of what's on the launcher:

['nautilus-home.desktop', '/opt/google/chrome/google-chrome.desktop', 'apps.desktop', 'geany.desktop', 'libreoffice-startcenter.desktop', 'gnome-terminal.desktop', 'gcalctool.desktop', 'Science.desktop', 'gimp.desktop', 'inkscape.desktop', 'ubuntu-software-center.desktop', 'alarm-clock-applet.desktop']

so you can do something like this in bash:

list=`gsettings get com.canonical.Unity.Launcher favorites`
newlist=`echo $list | sed s/]/", '${myfile}']"/`
gsettings set com.canonical.Unity.Launcher favorites "$newlist"

I tested and it works to add firefox to the launcher, however the icon doesn't display immediately. You'll have to log out/in or do a unity --replace command.

share|improve this answer
If you want to change the settings for other users, use sudo -u username dbus-launch --exit-with-session gsettings set com.canonical.Unity.Launcher favorites "$newlist". See – uzhoasit May 24 '14 at 21:20

Run the following command:

xdg-desktop-menu install --novendor /path/to/app-name.desktop

The app-name.desktop file would look something like this:

[Desktop Entry]
Name=App Name
Comment=A description of the app
share|improve this answer
Thanks for the help, but that doesn't pin it on the Unity launcher. – HDave Jul 18 '12 at 19:17
unity --replace? – SirCharlo Jul 18 '12 at 19:25
While this added it in the um... launcher thingy (Dash home) it did not pin it, even with unity --replace. However I could easily pin it after this by dragging it from the dash to the sidebar. – dlamblin Jan 14 '13 at 21:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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