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?
2 Answers
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:
#!/bin/bash
myfile='firefox.desktop'
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.
-
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 stackoverflow.com/a/23849268/2746945– uzhoasitMay 24, 2014 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
Exec=/path/to/app
TryExec=/path/to/app
Icon=/path/to/app-icon.ico
StartupNotify=false
Terminal=false
Type=Application
Categories=App-Category
-
-
-
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.– dlamblinJan 14, 2013 at 21:01
ls -dF .*
I don't know which you need, there are files for just about every application you run.