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)