fixed env and log file path

This commit is contained in:
Tordarus 2021-09-28 21:05:45 +02:00
parent 303051fd46
commit e3cc322594

View File

@ -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)