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/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))
}
}