0

I am using the gsettings tool to set up system proxy automatically[System Settings-> Network proxy], SO i made a simple bash script with these lines:

 gsettings set org.gnome.system.proxy mode 'auto'
 //for another mode
 gsettings set org.gnome.system.proxy mode 'none'

I place this script in /etc/network/if-up.d because I want the script to run when my laptop connects to the internet. I saved a copy of the script in my home folder and when i run the copy, the script seems to work fine and i can see the changes in network proxy window however when i run the script in /etc/network/if-up.d folder, the settings don't seem to be applied for some reason. What am i missing here?

4

1 回答 1

0

我终于使脚本工​​作了!自从我被gsettings 工具卡住已经一周了 。现在,我想要完成的是运行 gsettings 工具来为用户设置代理,尽管这样做的 bash 脚本归 root 所有,因此只有 root 环境变量。现在这可以推广到任何命令,要以特定用户身份运行 commad,我们可以这样做:

su username -c "command to execute"
#replace username by your username in the bash script

如果该命令仅包含一个单词,则可以删除双引号。我太高兴了。每次连接到互联网时,我都不需要切换配置文件并手动设置代理配置[IP 地址等]。

希望这可以帮助有类似问题的人:D

于 2013-01-08T17:24:09.667 回答