now prints the absolute path

This commit is contained in:
Niklas 2020-10-27 22:26:09 +01:00
parent 1b14fcbea4
commit 9592e4bb63

14
main.go
View File

@ -9,6 +9,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path" "path"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -135,6 +136,15 @@ func getNextWait(config sunsetConfig) (int, int) {
return diffHr, diffMin 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) { func block(config sunsetConfig, command string) {
for { for {
nextHr, nextMin := getNextWait(config) nextHr, nextMin := getNextWait(config)
@ -176,9 +186,7 @@ func main() {
} }
block(conf, *blockCommand) block(conf, *blockCommand)
} else { } else {
index := currentIndex(conf) fmt.Printf("%s", currentImage(*configFile, conf))
absoluteImagePath := path.Join(path.Dir(*configFile), conf.Files[index].File)
fmt.Printf("%s", absoluteImagePath)
} }
} }