In order to automatically configure fresh installations, I need a way to unlock the default applications from the launcher bar. Don't know where this information is stored, may be editing/substituting the file would be the easiest way.
Asked
Active
Viewed 1,863 times
1 Answers
1
The command to get the current launcher's icons is:
gsettings get com.canonical.Unity.Launcher favorites
This will give you a list like:
['item_1', 'item_2', 'application://application_to_remove.desktop', 'etc']
If you remove your item from the list and set the altered version of the list by the command:
gsettings set com.canonical.Unity.Launcher favorites "['item_1', 'item_2', 'etc']"
(mind the double quotes)
Your application is unlocked from the launcher.
Example script
As an example of how the job can be done by a (python) script:
#!/usr/bin/env python3
import subprocess
import sys
key = "com.canonical.Unity.Launcher"
desktopfile = sys.argv[1]
curr_launcher = eval(subprocess.check_output([
"gsettings", "get", key, "favorites"
]).decode("utf-8"))
new_launcher = [item for item in curr_launcher if not desktopfile in item]
subprocess.Popen(["gsettings", "set", key,"favorites",str(new_launcher)])
How to use
- Paste the script into an empty file, save it as
remove_fromlauncher.py Run it by the command
python3 /path/to/remove_fromlauncher.py <application.desktop>or shorter:
python3 /path/to/remove_fromlauncher.py <application>Example remove Virtualbox:
python3 /path/to/remove_fromlauncher.py virtualbox.desktop
Note
Keep in mind that you cannot simply remove all items from the list; It also includes items which are not applications.
EDIT
Version of the script to remove multiple icons at once:
#!/usr/bin/env python3
import subprocess
import sys
key = "com.canonical.Unity.Launcher"
desktopfiles = sys.argv[1:]
for desktopfile in desktopfiles:
curr_launcher = eval(subprocess.check_output([
"gsettings", "get", key, "favorites"
]).decode("utf-8"))
new_launcher = [item for item in curr_launcher if not desktopfile in item]
subprocess.Popen(["gsettings", "set", key,"favorites",str(new_launcher)])
Usage is pretty much the same, but now you can use multiple argumnents at once, e.g.:
python3 /path/to/remove_fromlauncher.py gedit thunderbird
will remove both Thunderbird and Gedit from the launcher.
Jacob Vlijm
- 85,675
gsettings seton Ubuntu 14.04 and it has no effect. – Luís de Sousa Apr 17 '16 at 12:57gsettings set com.canonical.Unity.Launcher favorites "['item_1', 'item_2', 'etc']". Has no visible effect, the Launcher remains the same. – Luís de Sousa Apr 17 '16 at 18:11