diff --git a/main.go b/main.go index 7a8c654..900afd3 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path" + "path/filepath" "strconv" "strings" "time" @@ -135,6 +136,15 @@ func getNextWait(config sunsetConfig) (int, int) { return diffHr, diffMin } +func currentImage(configPath string, config sunsetConfig) string { + index := currentIndex(config) + absFile, err := filepath.Abs(path.Join(path.Dir(configPath), config.Files[index].File)) + if err != nil { + log.Panic(err) + } + return absFile +} + func block(config sunsetConfig, command string) { for { nextHr, nextMin := getNextWait(config) @@ -176,9 +186,7 @@ func main() { } block(conf, *blockCommand) } else { - index := currentIndex(conf) - absoluteImagePath := path.Join(path.Dir(*configFile), conf.Files[index].File) - fmt.Printf("%s", absoluteImagePath) + fmt.Printf("%s", currentImage(*configFile, conf)) } }