[英]How do I set gsettings during startup?
I have a pxe server which hosts a live image of Ubuntu 12.04 and I would like to enable VNC on it. 我有一个pxe服务器,该服务器托管Ubuntu 12.04的实时映像,我想在其上启用VNC。
Normally I would do this with the following command: 通常,我将使用以下命令执行此操作:
$ gsettings set org.gnome.Vino enabled true $ gsettings set org.gnome.Vino已启用true
However, since this live OS lives in RAM it will need to do this on bootup every time. 但是,由于此实时操作系统位于RAM中,因此每次启动时都需要执行此操作。 The problem is for some reason it will not work with a script in /etc/init.d/... For the life of me I cannot figure out why gsettings doesn't work in this context.. 问题是由于某种原因,它不能与/etc/init.d/中的脚本一起使用。。。对我而言,我无法弄清楚为什么gsettings在这种情况下不起作用。
For reference this is the script I am using in /etc/init.d: 作为参考,这是我在/etc/init.d中使用的脚本:
#!/bin/bash
log=/var/log/gsettings.log
#Needed for some reason.. received info from http://stackoverflow.com/questions/10374520/gsettings-with-cron
sessionfile=`find "${HOME}/.dbus/session-bus/" -type f`
export $(grep "DBUS_SESSION_BUS_ADDRESS" "${sessionfile}" | sed '/^#/d')
set_gsettings()
{
echo "Inside set_gsettings" >> $log
#Enable vino
gsettings set org.gnome.Vino enabled true 2>&1 >> $log
gsettings set org.gnome.Vino prompt-enabled false 2>&1 >> $log
}
case "$1" in
start)
echo "Inside IT-gsettings" >> $log
set_gsettings
;;
restart|reload|force-reload)
/etc/init.d/IT-gsettings start
;;
stop)
:
;;
*)
log_success_msg "Usage: /etc/init.d/IT-gsettings {start|stop|restart|reload|force-reload}"
exit 1
;;
esac
exit 0
In short, how can I set gsettings on startup? 简而言之,如何在启动时设置gsettings?
It is likely the script runs when still there is no session available. 当仍然没有会话可用时,脚本可能会运行。
Given it is a live CD and you have control of it, you might want to change the defaults values in the schema. 鉴于它是实时CD,并且您可以控制它,因此您可能希望更改架构中的默认值。 For vino, you should change the default values in /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml
. 对于vino,您应该在/usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml
更改默认值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.