1
0
Fork 0

Move files to config dir (manual for now)

This commit is contained in:
Andrew Tomaka 2024-06-06 01:05:29 -04:00
parent 06486ea395
commit 76036dbf67
Signed by: atomaka
GPG key ID: 61209BF70A5B18BE
4 changed files with 15 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

24
main.go
View file

@ -29,6 +29,12 @@ var keymap = map[string]hotkey.Key{
} }
func main() { func main() {
userConfigDir, _ := os.UserConfigDir()
appConfigDir := userConfigDir + "/keyboard-layer-display"
imageDir := appConfigDir + "/layers"
log.Println(imageDir)
os.MkdirAll(imageDir, 0755)
a := app.New() a := app.New()
w := a.NewWindow("SysTray") w := a.NewWindow("SysTray")
@ -46,29 +52,29 @@ func main() {
Width: 1656 / 2, Width: 1656 / 2,
Height: 546 / 2, Height: 546 / 2,
}) })
defaultImage := canvas.NewImageFromFile("./default.png")
defaultImage := canvas.NewImageFromFile(imageDir + "/default.png")
w.SetContent(container.NewPadded(defaultImage))
w.SetCloseIntercept(func() {
w.Hide()
})
layers := []Layer{} layers := []Layer{}
for i := range 5 { for i := range 5 {
imagePath := "./layer_" + strconv.Itoa(i+1) + ".png" imagePath := imageDir + "/layer_" + strconv.Itoa(i+1) + ".png"
if _, err := os.Stat(imagePath); errors.Is(err, os.ErrNotExist) { if _, err := os.Stat(imagePath); errors.Is(err, os.ErrNotExist) {
continue continue
} }
newLayer := Layer{ newLayer := Layer{
Image: canvas.NewImageFromFile(imagePath), Image: canvas.NewImageFromFile(imagePath),
Hotkey: keymap["KeyF"+strconv.Itoa(12+i)], Hotkey: keymap["KeyF"+strconv.Itoa(13+i)],
} }
layers = append(layers, newLayer) layers = append(layers, newLayer)
} }
w.SetContent(container.NewPadded(defaultImage))
w.SetCloseIntercept(func() {
w.Hide()
})
go func() { go func() {
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
wg.Add(len(layers)) wg.Add(len(layers))