简体   繁体   English

如何在启动过程中设置gsettings?

[英]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.

相关问题 在启动期间崩溃时如何使用 gdb 调试可执行文件? - How do I debug an executable with gdb when it crashes during startup? 如何在Raspberry PI中启动时设置.java程序? - How do I set a .java program in startup in a Raspberry PI? 如何为 Gnome 和 Gtk 配​​置 GSettings - How to configure GSettings for Gnome and Gtk 服务器重启后如何让mongodb副本集节点“启动”? - How do I make a mongodb replica set node "startup" after the server restarts? 我想在启动时执行脚本(.sh文件),以便可以设置鼠标的灵敏度。 我怎样才能做到这一点? - I want to execute a script (.sh file) on startup so that I can set the sensitivity of my mouse. How can I do this? 如何使用Vala从GSettings中存储的字典数组中读取值? - How can I read a value from an array of dictionaries stored in GSettings with Vala? 我可以在不重新登录的情况下应用gsettings吗? - can i apply gsettings without relogin? 如何设置 flatpak 应用程序在启动时运行? - How can I set a flatpak application to run on startup? 如何在启动时创建共享tmux会话? - How do I create a shared tmux session at startup? 如何在 Linux 上启动时运行 shell 命令? - How do I run a shell command on startup on Linux?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM