Skip to content

Commit

Permalink
Merge pull request #4 from zxcv32/fix/kde
Browse files Browse the repository at this point in the history
feat!: unsupported config updater
  • Loading branch information
zxcv32 authored Nov 5, 2022
2 parents 2f80ea0 + ddff6cf commit 1887f00
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 47 deletions.
38 changes: 0 additions & 38 deletions configs/config.toml

This file was deleted.

22 changes: 14 additions & 8 deletions internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package internal

import (
"fmt"
"os"

log "github.com/sirupsen/logrus"
Expand All @@ -21,7 +22,8 @@ import (
// LoadConfig Load configuration and return the path of config directory
func LoadConfig() string {
// Load config
path := "configs"
home, _ := os.UserHomeDir()
path := home + "/.config/OpenRWC"
file := "config"
if _, err := os.Stat(path + "/" + file + ".toml"); os.IsNotExist(err) {
path, file := createDefaultConfig()
Expand All @@ -32,16 +34,21 @@ func LoadConfig() string {
}
return path
} else {
pwd, pwdErr := os.Getwd()
if pwdErr != nil {
log.Fatal(pwdErr)
}
path = pwd + "/" + path
setupViper(path, file, "toml") // Usually location in project
err := viper.ReadInConfig()
if err != nil {
log.Fatal(err.Error())
}
if viper.GetString("version") != "0.0.2" { // set supported configuration version
log.Warnf(fmt.Sprintf("Installed configuration version (\"%s\") is unsupported. It is backed up with `.old` extension!", viper.GetString("version")))
old := path + "/" + file + ".toml"
backup := path + "/" + file + ".toml.old"
err := os.Rename(old, backup)
if nil != err {
log.Fatal(err)
}
return LoadConfig()
}
return path
}
}
Expand Down Expand Up @@ -105,8 +112,7 @@ util_param = "set-scaled"
log.Fatal(openError)
}
defer f.Close()
output, writeError := f.WriteString(template)
log.Infof(string(output))
_, writeError := f.WriteString(template)
if writeError != nil {
log.Fatal(writeError)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/nitrogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
func NitrogenChange(wallpaper string) error {
monitors := viper.GetInt("openrwc.monitors")
for i := 0; i < monitors; i++ {
_, err := exec.Command("nitrogen", "--"+viper.GetString("openrwc.nitrogen_param"),
_, err := exec.Command("nitrogen", "--"+viper.GetString("openrwc.util_param"),
wallpaper, fmt.Sprintf("--head=%d", i)).Output()
if nil != err {
return err
Expand Down

0 comments on commit 1887f00

Please sign in to comment.