Esempio n. 1
0
//Default config: /usr/share/config/kdm/kdmrc
func getKDMAutoLoginUser(file string) (string, error) {
	if !dutils.IsFileExist(file) {
		return "", fmt.Errorf("Not found this file: %s", file)
	}

	v, exist := dutils.ReadKeyFromKeyFile(file,
		"X-:0-Core", "AutoLoginEnable", true)
	if !exist {
		return "", nil
	}

	enable, ok := v.(bool)
	if !ok {
		return "", fmt.Errorf("The value's type error.")
	}

	if !enable {
		return "", nil
	}

	v, exist = dutils.ReadKeyFromKeyFile(file,
		"X-:0-Core", "AutoLoginUser", "")
	if !exist {
		return "", nil
	}

	var name string
	name, ok = v.(string)
	if !ok {
		return "", fmt.Errorf("The value's type error.")
	}

	return name, nil
}
Esempio n. 2
0
func getDscConfInfo() (isUpdate bool, duration int32) {
	isUpdate = true
	duration = 3

	homeDir := dutils.GetHomeDir()
	filename := path.Join(homeDir, DSC_CONFIG_PATH)
	if !dutils.IsFileExist(filename) {
		return
	}

	str, _ := dutils.ReadKeyFromKeyFile(filename,
		"update", "auto", "")
	if v, ok := str.(string); ok && v == "False" {
		isUpdate = false
	}

	interval, ok1 := dutils.ReadKeyFromKeyFile(filename,
		"update", "interval", int32(0))
	if ok1 {
		if i, ok := interval.(int32); ok {
			duration = int32(i)
		}
	}

	return

}
Esempio n. 3
0
/**
 * If icon theme index.theme has 'Directories', it's valid.
 **/
func hasDirectories(filename string) bool {
	if !dutils.IsFileExist(filename) {
		return false
	}

	v, ok := dutils.ReadKeyFromKeyFile(filename,
		"Icon Theme", "Directories", "")
	if !ok || len(v.(string)) == 0 {
		return false
	}

	return true
}
Esempio n. 4
0
func isIconHidden(filename string) bool {
	if !dutils.IsFileExist(filename) {
		return true
	}

	v, ok := dutils.ReadKeyFromKeyFile(filename,
		"Icon Theme", "Hidden", false)
	if !ok {
		return false
	}

	return v.(bool)
}
Esempio n. 5
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
}
Esempio n. 6
0
func isGuestUserEnabled() bool {
	v, exist := dutils.ReadKeyFromKeyFile(actConfigFile,
		actConfigGroupGroup, actConfigKeyGuest, true)
	if !exist {
		return false
	}

	ret, ok := v.(bool)
	if !ok {
		return false
	}

	return ret
}
Esempio n. 7
0
//Default config: /etc/gdm/custom.conf
func getGDMAutoLoginUser(file string) (string, error) {
	if !dutils.IsFileExist(file) {
		return "", fmt.Errorf("Not found this file: %s", file)
	}

	v, exist := dutils.ReadKeyFromKeyFile(file,
		"daemon", "AutomaticLogin", "")
	if !exist {
		return "", nil
	}

	name, ok := v.(string)
	if !ok {
		return "", fmt.Errorf("The value's type error.")
	}

	return name, nil
}
Esempio n. 8
0
//Default config: /etc/lightdm/lightdm.conf
func getLightdmAutoLoginUser(file string) (string, error) {
	if !dutils.IsFileExist(file) {
		return "", fmt.Errorf("Not found this file: %s", file)
	}

	v, exist := dutils.ReadKeyFromKeyFile(file,
		"SeatDefaults", "autologin-user", "")
	if !exist {
		return "", nil
	}

	name, ok := v.(string)
	if !ok {
		return "", fmt.Errorf("The value's type error.")
	}

	return name, nil
}
Esempio n. 9
0
func getIconDirList(iconPath string) []string {
	list := []string{}
	if !dutils.IsFileExist(iconPath) {
		return list
	}

	filename := path.Join(iconPath, ICON_CONFIG)
	dirList, ok := dutils.ReadKeyFromKeyFile(filename,
		"Icon Theme", "Directories", list)
	if !ok {
		return list
	}

	var tList []string
	if tList, ok = dirList.([]string); !ok {
		return list
	}

	for _, n := range tList {
		strs := strings.Split(n, ",")
		for _, t := range strs {
			if strings.Contains(t, "scalable") {
				continue
			}

			name := path.Join(iconPath, t)
			if !dutils.IsFileExist(name) {
				continue
			}

			list = append(list, name)
		}
	}

	return list
}