Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
home directory discovery
  • Loading branch information
amirdaaee committed Jul 23, 2023
1 parent 891ea30 commit b8178ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 15 additions & 2 deletions color.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/sirupsen/logrus"
)

const stateFile = "~/.config/OpenRGB-switch/state"
const colorFile = "~/.config/OpenRGB-switch/colors"
var stateFile string //= "~/.config/OpenRGB-switch/state"
var colorFile string // = "~/.config/OpenRGB-switch/colors"

type Color struct {
R uint8
Expand Down Expand Up @@ -136,3 +136,16 @@ func parseCurrent(ctrl *Controller) error {
logrus.WithField("val", ctrl.Current).Debug("current state parsed")
return nil
}
func init() {
home, err := os.UserHomeDir()
if err != nil {
logrus.Panic(err)
}
err = os.MkdirAll(home+"/.config/OpenRGB-switch", os.ModePerm)
if err != nil {
logrus.Panic(err)
}
stateFile = home + "/.config/OpenRGB-switch/state"
colorFile = home + "/.config/OpenRGB-switch/colors"

}
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"flag"
"os"

"github.com/sirupsen/logrus"
)
Expand All @@ -13,7 +12,6 @@ func init() {
if *verbose {
logrus.SetLevel(logrus.DebugLevel)
}
os.MkdirAll("~/.config/OpenRGB-switch", os.ModePerm)
}
func main() {
ctrl, err := NewController()
Expand Down

0 comments on commit b8178ec

Please sign in to comment.