如何在启动期间设置gsettings?

Dan*_*nMD 4 linux ubuntu gnome init ubuntu-12.04

我有一个pxe服务器,它托管Ubuntu 12.04的实时图像,我想在其上启用VNC.

通常我会使用以下命令执行此操作:

$ gsettings设置org.gnome.Vino启用true

但是,由于这个实时操作系统存在于RAM中,因此每次都需要在启动时执行此操作.问题是由于某种原因,它不适用于/etc/init.d /中的脚本...对于我的生活,我无法弄清楚为什么gsettings在这种情况下不起作用..

作为参考,这是我在/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
Run Code Online (Sandbox Code Playgroud)

简而言之,我如何在启动时设置gsettings?

gpo*_*poo 5

当仍然没有可用的会话时,脚本可能会运行.

鉴于它是一张Live CD并且您可以控制它,您可能希望更改架构中的默认值.对于vino,您应该更改默认值/usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml.