I'm writing a bash script that modifies a program, then adds an icon to the unity launcher. Although I've created the .desktop file in /usr/share/applications, I can't see a way to programmatically add the shortcut to the launcher.
1 Answer
- First get the list of applications from the launcher:
$ gsettings get com.canonical.Unity.Launcher favorites
Make an array of the items.
Then have your install script add your application to the array
Then have your script add the items from the created array to this command with item comma separated:
$ gsettings set com.canonical.Unity.Launcher favorites "['app1','app2','app3','your program.desktop']"
The app# is the applications from the array that you are including in your installer script.
Replace your program with the name of the *.desktop
launcher you created.
Update:
The procedure is listed above.
This is a command line that will append your application to the launcher
gsettings set com.canonical.Unity.Launcher favorites "$(gsettings get com.canonical.Unity.Launcher favorites | sed "s/]/,'Your Program.desktop']/")"
Add the above commandline to your install script. Replace the bold Your Program.desktop with the program you created. This will not clobber what your current icons. It'll append.
-
-
You have that error because there isn't a key
favourites
. I understand dependent on the language dialect there's a difference in spelling. But the required keyname in Ubuntu isfavorites
. Try copying and pasting the command. Then change only what is highlighted in bold. Feb 16, 2017 at 13:05 -
It's not clear to me what you're saying about adding one... Are you saying adding an Icon for the desktop launcher, or are you saying adding an icon to the Ubuntu Launcher. The command adds a created desktop launcher, which the user has created and placed in his applications folder, to Ubuntu's side bar launcher. It won't affect the icon. Whatever icon is already included in the *.desktop file the user has create, will app in the launcher. The user call manually right click and stick a applicaton to the launcher. This command will allow the OP's installer script to do this. Feb 16, 2017 at 14:10
-
2Simply:
gsettings set com.canonical.Unity.Launcher favorites "['your program.desktop']"
sets the launcher to"['your program.desktop']"
. It removes all other icons, which definitely is not the intention of OP. Did you try the command? Feb 16, 2017 at 14:12 -
Now I see what you are saying... Thanks. I'll fix the answer. Your refernce to single icon to the launcher. Feb 16, 2017 at 14:16