예제 #1
0
func setKDMAutoLoginUser(name, file string) error {
	success := dutils.WriteKeyToKeyFile(file,
		"X-:0-Core", "AutoLoginEnable", true)
	if !success {
		return fmt.Errorf("Set 'AutoLoginEnable' to 'true' failed!")
	}

	success = dutils.WriteKeyToKeyFile(file,
		"X-:0-Core", "AutoLoginUser", name)
	if !success {
		return fmt.Errorf("Set autologin user for %q failed!", name)
	}

	return nil
}
예제 #2
0
func (cursor *CursorTheme) Set(theme string) error {
	if !IsNameInInfoList(theme, cursor.infoList) {
		return errInvalidTheme
	}

	// Ignore xsettings error
	setThemeViaXSettings(theme)
	fixedQtCursor(theme)

	dir := path.Join(os.Getenv("HOME"), ".icons/default")
	if !dutils.IsFileExist(dir) {
		err := os.MkdirAll(dir, dirModePerm)
		if err != nil {
			return err
		}
	}
	filename := path.Join(dir, "index.theme")
	ok := dutils.WriteKeyToKeyFile(filename,
		"Icon Theme", "Inherits", theme)
	if !ok {
		return errWriteCursor
	}

	return nil
}
예제 #3
0
func setGDMAutoLoginUser(name, file string) error {
	success := dutils.WriteKeyToKeyFile(file,
		"daemon", "AutomaticLogin", name)
	if !success {
		return fmt.Errorf("Set autologin user for %q failed!", name)
	}

	return nil
}
예제 #4
0
func setLightdmAutoLoginUser(name, file string) error {
	success := dutils.WriteKeyToKeyFile(file,
		"SeatDefaults", "autologin-user", name)
	if !success {
		return fmt.Errorf("Set autologin user for %q failed!", name)
	}

	return nil
}
예제 #5
0
func setQtCursorBlink(rate uint32, filename string) error {
	ok := dutils.WriteKeyToKeyFile(filename, "Qt",
		"cursorFlashTime", rate)
	if !ok {
		return fmt.Errorf("Set Qt CursorBlink Failed")
	}

	return nil
}
예제 #6
0
func setQt4Theme(config string) error {
	value, _ := dutils.ReadKeyFromKeyFile(config, "Qt", "style", "")

	if value == "GTK+" {
		return nil
	}
	ok := dutils.WriteKeyToKeyFile(config, "Qt", "style", "GTK+")
	if !ok {
		return errWriteValue
	}

	return nil
}
예제 #7
0
func (fs *FontSettings) setQtFont(name, sizeStr string) error {
	if len(name) < 1 || len(sizeStr) < 1 {
		return errors.New("Set Qt Font args error")
	}

	homeDir := dutils.GetHomeDir()
	if len(homeDir) < 1 {
		return errors.New("Get home dir failed")
	}

	filename := path.Join(homeDir, _QT_CONFIG_FILE)
	value := "\"" + name + "," + sizeStr + _QT_FONT_ARGS + "\""
	if !dutils.WriteKeyToKeyFile(filename, _QT_KEY_GROUP,
		_QT_KEY_FONT, value) {
		return errors.New("Set Qt font failed")
	}

	return nil
}
예제 #8
0
func (m *Manager) AllowGuestAccount(dbusMsg dbus.DMessage, allow bool) error {
	pid := dbusMsg.GetSenderPID()
	err := m.polkitAuthManagerUser(pid, "AllowGuestAccount")
	if err != nil {
		return err
	}

	if allow == isGuestUserEnabled() {
		return nil
	}

	success := dutils.WriteKeyToKeyFile(actConfigFile,
		actConfigGroupGroup, actConfigKeyGuest, allow)
	if !success {
		reason := "Enable guest user failed"
		triggerSigErr(pid, "AllowGuestAccount", reason)
		return fmt.Errorf(reason)
	}
	m.setPropAllowGuest(allow)

	return nil
}
예제 #9
0
func setQt4Font(config, name string, size int32) {
	value := fmt.Sprintf("\"%s, %v, -1, 5, 50, 0, 0, 0, 0, 0\"",
		name, size)
	dutils.WriteKeyToKeyFile(config, "Qt", "font", value)
}