Created
December 11, 2022 12:27
-
-
Save larrasket/9d32d183604899a179be5c1714f54c10 to your computer and use it in GitHub Desktop.
Go program to pop up an image every 4 hours; as a remainder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io/ioutil" | |
"log" | |
"math/rand" | |
"os/exec" | |
"time" | |
) | |
const ( | |
image_command = "imv" | |
images_directory = "/home/ghd/me/pic/mot/" | |
) | |
func main() { | |
files, err := ioutil.ReadDir(images_directory) | |
if err != nil { | |
log.Fatalf("Couldn't reach images directory %s: %s", images_directory, err) | |
} | |
rand.Seed(time.Now().UnixNano()) | |
rand.Shuffle(len(files), func(i, j int) { files[i], files[j] = files[j], files[i] }) | |
tk := time.NewTicker(3 * time.Hour) | |
for i := 0; true; <-tk.C { | |
f := files[i%len(files)] | |
exec.Command(image_command, "-f", images_directory+f.Name()).Output() | |
i++ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment