diff --git a/main.go b/main.go index 900afd3..e5e7bd1 100644 --- a/main.go +++ b/main.go @@ -145,18 +145,21 @@ func currentImage(configPath string, config sunsetConfig) string { return absFile } -func block(config sunsetConfig, command string) { +func block(configPath string, config sunsetConfig, command string) { + image := currentImage(configPath, config) + go runCommand(command, image) for { nextHr, nextMin := getNextWait(config) timer := time.NewTimer((time.Duration(nextHr) * time.Hour) + (time.Duration(nextMin) * time.Minute)) <-timer.C log.Printf("Running command: %s\n", command) - go runCommand(command) + image := currentImage(configPath, config) + go runCommand(command, image) } } -func runCommand(command string) { - cmd := exec.Command("/usr/bin/env", "sh", "-c", command) +func runCommand(command, image string) { + cmd := exec.Command(command, image) err := cmd.Run() if err != nil { log.Printf("Command %s returned a non 0 code", command) @@ -184,7 +187,7 @@ func main() { fmt.Println("Must provide a command.") os.Exit(1) } - block(conf, *blockCommand) + block(*configFile, conf, *blockCommand) } else { fmt.Printf("%s", currentImage(*configFile, conf)) }