Example #1
0
func getCursorList() []pathInfo {
	list := []pathInfo{}
	sysDirs := []pathInfo{pathInfo{ICON_SYS_PATH, THEME_TYPE_SYS}}
	conditions := []string{"cursors"}
	sysList := getThemeList(sysDirs, conditions)

	homeDir := dutils.GetHomeDir()
	if len(homeDir) < 1 {
		list = sysList
		return list
	}

	dir := path.Join(homeDir, ICON_LOCAL_PATH)
	localDirs := []pathInfo{pathInfo{dir, THEME_TYPE_LOCAL}}
	localList := getThemeList(localDirs, conditions)

	list = localList
	for _, l := range sysList {
		if isPathThemeInList(l, list) {
			continue
		}
		list = append(list, l)
	}

	return list
}
Example #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

}
Example #3
0
func (m *Manager) modifyCustomTheme(info *Theme) bool {
	homeDir := dutils.GetHomeDir()
	dir := path.Join(homeDir, userThemePath, "Custom")
	if !dutils.IsFileExist(dir) {
		err := os.MkdirAll(dir, dirPermMode)
		if err != nil {
			logger.Debug(err)
			return false
		}
	}

	filename := path.Join(dir, "theme.ini")
	var newFile bool
	if !dutils.IsFileExist(filename) {
		err := dutils.CopyFile(tempDThemeCustom, filename)
		if err != nil {
			logger.Debug(err)
			return false
		}
		newFile = true
	}

	kFile := glib.NewKeyFile()
	defer kFile.Free()
	_, err := kFile.LoadFromFile(filename,
		glib.KeyFileFlagsKeepComments|
			glib.KeyFileFlagsKeepTranslations)
	if err != nil {
		return false
	}

	kFile.SetString(groupKeyComponent, themeKeyGtk, info.GtkTheme)
	kFile.SetString(groupKeyComponent, themeKeyIcon, info.IconTheme)
	kFile.SetString(groupKeyComponent, themeKeyCursor, info.CursorTheme)
	kFile.SetString(groupKeyComponent, themeKeySound, info.SoundTheme)
	kFile.SetString(groupKeyComponent, themeKeyBackground, info.Background)
	kFile.SetString(groupKeyComponent, themeKeyFontName, info.FontName)
	kFile.SetString(groupKeyComponent, themeKeyFontMono, info.FontMono)
	kFile.SetInteger(groupKeyComponent, themeKeyFontSize, info.FontSize)

	_, contents, err := kFile.ToData()
	if err != nil {
		return false
	}

	m.wLocker.Lock()
	defer m.wLocker.Unlock()
	ok := dutils.WriteStringToKeyFile(filename, contents)
	if newFile && ok {
		touchFile()
	}

	return ok
}
Example #4
0
func (kbd *Keyboard) setGreeterLayoutList(list []string) {
	if kbd.greeter == nil {
		return
	}

	username := dutils.GetUserName()
	homeDir := dutils.GetHomeDir()
	if homeDir == path.Join("/tmp", username) && len(username) == 0 {
		return
	}
	kbd.greeter.SetKbdLayoutList(username, list)
}
Example #5
0
func main() {
	defer func() {
		if err := recover(); err != nil {
			logger.Debugf("Error: %v\n", err)
			os.Exit(0)
		}
	}()

	if C.init_env() == 0 {
		logger.Debug("Can't generate thumbnails, try run this program under an X11 enviorment")
		return
	}

	if len(os.Args) < 2 {
		printHelper()
		return
	}

	op := os.Args[1]
	outDir := ""
	homeDir := dutils.GetHomeDir()
	if len(homeDir) > 0 {
		outDir = path.Join(homeDir, PERSON_LOCAL_THUMB_PATH)
	}
	if len(os.Args) == 3 {
		outDir = os.Args[2]
	}

	if !isVersionSame() {
		cleanThumbCache()
		forceFlag = true
	}

	switch op {
	case "-a":
		doGenGtkThumb(forceFlag, outDir)
		doGenIconThumb(forceFlag, outDir)
		doGenCursorThumb(forceFlag, outDir)
		doGenBgThumb(forceFlag, outDir)
	case "--gtk":
		doGenGtkThumb(forceFlag, outDir)
	case "--icon":
		doGenIconThumb(forceFlag, outDir)
	case "--cursor":
		doGenCursorThumb(forceFlag, outDir)
	case "--background":
		doGenBgThumb(forceFlag, outDir)
	default:
		logger.Debugf("Invalid option: %s\n\n", op)
		printHelper()
	}
}
Example #6
0
func (dapp *DefaultApps) Reset() bool {
	homeDir := dutils.GetHomeDir()
	if len(homeDir) < 1 {
		logger.Warning("Get homeDir failed")
		return false
	}
	if err := os.Remove(homeDir + "/" + MIME_CACHE_FILE); err != nil {
		logger.Warning("Delete '%s' failed: %v",
			homeDir+"/"+MIME_CACHE_FILE, err)
		return false
	}
	_TerminalGSettings().Reset("exec")

	return true
}
Example #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
}
Example #8
0
func getBgList() []pathInfo {
	list := []pathInfo{}

	if tmp, ok := getImageList(BG_DEFAULT_PATH); ok {
		for _, l := range tmp {
			t := pathInfo{}
			t.Path = l
			t.T = THEME_TYPE_SYS
			list = append(list, t)
		}
	}

	// system bg
	if dirs, ok := getBgDir(PERSON_SYS_THEME_PATH); ok {
		for _, d := range dirs {
			if tmp, ok := getImageList(d); ok {
				for _, l := range tmp {
					t := pathInfo{}
					t.Path = l
					t.T = THEME_TYPE_SYS
					if !isPathBgInList(t, list) {
						list = append(list, t)
					}
				}
			}
		}
	}

	homeDir := dutils.GetHomeDir()
	if len(homeDir) < 1 {
		return list
	}
	// local bg
	if dirs, ok := getBgDir(path.Join(homeDir, PERSON_LOCAL_THEME_PATH)); ok {
		for _, d := range dirs {
			if tmp, ok := getImageList(d); ok {
				for _, l := range tmp {
					t := pathInfo{}
					t.Path = l
					t.T = THEME_TYPE_LOCAL
					if !isPathBgInList(t, list) {
						list = append(list, t)
					}
				}
			}
		}
	}
	pict := getUserPictureDir()
	userBG := path.Join(pict, "Wallpapers")
	if !dutils.IsFileExist(userBG) {
		return list
	}
	if tmpList, ok := getImageList(userBG); ok {
		for _, l := range tmpList {
			tmp := pathInfo{}
			tmp.Path = l
			tmp.T = THEME_TYPE_LOCAL
			list = append(list, tmp)
		}
	}

	return list
}