Move files to config dir (manual for now)
This commit is contained in:
parent
06486ea395
commit
76036dbf67
4 changed files with 15 additions and 9 deletions
BIN
default.png
BIN
default.png
Binary file not shown.
Before Width: | Height: | Size: 120 KiB |
BIN
layer_1.png
BIN
layer_1.png
Binary file not shown.
Before Width: | Height: | Size: 119 KiB |
BIN
layer_2.png
BIN
layer_2.png
Binary file not shown.
Before Width: | Height: | Size: 119 KiB |
24
main.go
24
main.go
|
@ -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))
|
||||||
|
|
Loading…
Reference in a new issue