On Ubuntu 13.10, I have all of my gsettings in a file, mygset.sh. For example, mygset.sh contains many lines such as
gsettings set com.canonical.Unity.Launcher favorites "['application://nautilus.desktop', 'application://firefox.desktop', 'application://chromium-browser.desktop', 'unity://running-apps', 'unity://expo-icon', 'unity://devices']"
I have a master install script that I have to run with sudo (e.g. it does sudo apt-get install).
From that master install script I want to call mygset.sh
. However, no matter how I call it it is not changing the settings for my user. I think it is changing the settings of root. I've tried it like (from masterinstall.sh
which is being run as sudo ./masterinstall.sh
):
sudo -u "wang" ./mygset.sh
sudo -u "wang" bash -c ./mygset.sh
Neither of those works (they run without error and change the setting [I check within the script with gsetting get] but not for user "wang").
When I run mygset.sh
from the command line (without sudo: bash ./mygset.sh
). It works perfectly. Why is there this difference and what can I do to solve it within masterinstall.sh
?
I recommend you write a 'parent' script, which can then launch the masterinstall using sudo before running myget again as the local user. Examples follows:
#!/bin/bash
sudo ./masterinstall.sh
./mygset.sh