I have written an install script which automates my install process. Afterwards I would like it to rearrange/add/remove the icons to the unity launcher.
Using dconf watch /
I can see output as I reorder the icons. Is there a command line way to do this – possibly with gsettings
?
Best Answer
Introduction
The simple script bellow allows taking a file as argument and sets the launcher to have whatever shortcuts to programs appear in the file (one per line).
Basic idea is that the launcher icons are actually links to
.desktop
files (wherever they may appear) , and canonical method to set the launcher items is to run the following command:This can get tedious if you want to add many items and quoting can become a pain. One can always open a desired program and right click on the icon to invoke the "Lock to launcher" option, but that also is not practical when you're dealing with large amount of items.
The approach taken here is to simply read a file, with 1 time per line, build up the command text , and execute it. This is no different from running the
gsettings set
command above, except that the hard work is done for you.Usage:
To run the script , save it to a file, make it executable with
chmod +x /path/to/script
and run asThe input file should contain full path to the items you want added to the launcher, such as
/usr/share/applications/firefox.desktop
, but it's not necessary , a line withfirefox.desktop
is OK too.Demo
Before running the script
After running the script
Note that the order is exactly the same as the entries appear in the input file
Script Source