Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This is more of a how to use command line instruction question more than how to add items to the Unity notification panel.

I have to have a one line CLI to add a new item to com.canonical.Unity.Panel systray-whitelist.

Standard procedure for doing so is:

sudo gsettings get com.canonical.Unity.Panel systray-whitelist

We get

['JavaEmbeddedFrame', 'Wine', 'Skype']

Then we do the second command

sudo gsettings set com.canonical.Unity.Panel systray-whitelist "['JavaEmbeddedFrame', 'Wine', 'Skype', 'shutter']"

While that's great and all, it requires people to copy and paste the result from the first line, and for a script i am writing I want to do it in one command.

So far this is what I have:

sudo gsettings set com.canonical.Unity.Panel systray-whitelist | gsettings get com.canonical.Unity.Panel systray-whitelist | sed -e "s/']$/,'shutter']/" | awk 'NF{print "\"" $0 "\""}'

I think I am missing something.

Firstly, I am not sure if I am piping the string into gsettings set function correctly. Secondly, while I think I am parsing the output from gsettings get function correctly, I wouldn't figure out a way to add the " " around the modified result using sed, so I had to pipe another awk command into this mess.

Thanks to anyone that helps.

share|improve this question
    
Have anyone tested this on Ubuntu 12.04? Its not working for me (it was working on previous versions) –  ilius Jun 9 '12 at 4:34
    
gsettings set com.canonical.Unity.Panel systray-whitelist "$(gsettings get com.canonical.Unity.Panel systray-whitelist | sed "s/, *'yourapp' *//g" | sed "s/'yourapp' *, *//g" | sed -e "s/]$/, 'yourapp']/")" try this one, replace yourapp with what you need. –  hansioux Jun 15 '12 at 9:22
add comment

1 Answer

up vote 8 down vote accepted

After hitting error after error, I finally figured why it didn't accept the quotes. You can simply place the quotes around the actual variable, no need to enter them in the actual command.

This will work:

gsettings set com.canonical.Unity.Panel systray-whitelist "$(gsettings get com.canonical.Unity.Panel systray-whitelist | sed -e "s/]$/, 'shutter']/")"

(Also, you need to remove the ' in sed -e "s/']$/ in your example for this to work).

Later edit: by the way, don't run gsettings with sudo... it won't work.

share|improve this answer
    
This new one line I came up with. This will remove any previous entries that might be the whitelist, and adding it again at the end. This is for install scripts. it's brute force but it works. gsettings set com.canonical.Unity.Panel systray-whitelist "$(gsettings get com.canonical.Unity.Panel systray-whitelist | sed "s/, *'yourapp' *//g" | sed "s/'yourapp' *, *//g" | sed -e "s/]$/, 'yourapp']/")" –  hansioux May 4 '11 at 1:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.