-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (36 loc) · 909 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"io/ioutil"
"log"
"os"
"github.com/yourfavoritedev/background-changer/helpers"
"github.com/yourfavoritedev/background-changer/ui"
"github.com/yourfavoritedev/background-changer/wallpaper"
)
func init() {
os.Setenv("wallpapersDir", "C:/Users/13236/Documents/wallpapers/")
// create cache file if it doesn't exist
_, err := helpers.ReadFile(wallpaper.CurrentWallPaperPath)
if err != nil {
err = helpers.WriteFile(wallpaper.CurrentWallPaperPath, []byte{})
if err != nil {
return
}
}
}
func main() {
// get files from directory
dir := os.Getenv("wallpapersDir")
files, err := ioutil.ReadDir(dir)
if err != nil {
log.Fatalf("failed to read from directory: %v", err)
return
}
// get all file names
fileNames := make([]string, len(files))
for i, file := range files {
fileNames[i] = file.Name()
}
// initialize termui
ui.CreateListWidget(fileNames)
}