From e3cc32259475b29a50d2d47f9bd05315ab20ac4b Mon Sep 17 00:00:00 2001 From: Tordarus Date: Tue, 28 Sep 2021 21:05:45 +0200 Subject: [PATCH] fixed env and log file path --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 2a1529e..37be73d 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "io/ioutil" "os" @@ -9,8 +10,12 @@ import ( "strings" ) +var ( + envFile = flag.String("env", "$HOME/.config/i3-wrapper/environment", "environment file with variable definitions") +) + func main() { - logFile, err := os.Create("/home/tordarus/.i3.log") + logFile, err := os.Create(filepath.Join(os.Getenv("HOME"), ".i3.log")) if err != nil { fmt.Fprintln(os.Stderr, err) } @@ -26,7 +31,7 @@ func main() { cmd.Stderr = os.Stderr cmd.Env = os.Environ() - if envData, err := ioutil.ReadFile(filepath.Join(os.Getenv("HOME"), ".config/i3wrapper/environment")); err == nil { + if envData, err := ioutil.ReadFile(os.ExpandEnv(*envFile)); err == nil { cmd.Env = append(cmd.Env, strings.Split(string(envData), "\n")...) } else { fmt.Println(err)