Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 4480  / 1 Year ago, sat, may 27, 2023, 6:36:45

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?


More From » unity

 Answers
7

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.


[#36768] Sunday, May 28, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
laceanz

Total Points: 86
Total Questions: 113
Total Answers: 104

Location: Australia
Member since Thu, Jan 26, 2023
1 Year ago
;