ditty/config.go

41 lines
793 B
Go
Raw Normal View History

2020-01-22 22:54:55 +00:00
package main
2024-10-02 06:16:39 +00:00
import "github.com/gopxl/beep/v2/speaker"
2020-01-22 22:54:55 +00:00
type appConfig struct {
Input map[string][]string // Keybinds
Layout string
Volume int // Starting volume
Remember bool
Dir string
2021-09-02 20:06:27 +00:00
QueueFiles []*libraryEntry
QueuePlaying int
AudioPosition int
2020-01-22 22:54:55 +00:00
}
var config = &appConfig{
Layout: defaultLayout,
Volume: defaultVolume,
Remember: true,
}
func clearAppState() {
config.Dir = ""
config.QueueFiles = nil
config.QueuePlaying = 0
config.AudioPosition = 0
}
2020-01-22 22:54:55 +00:00
func saveAppState() {
config.Dir = mainDirectory
config.QueueFiles = queueFiles
config.QueuePlaying = queuePlaying
speaker.Lock()
if playingStreamer == nil {
config.AudioPosition = 0
} else {
config.AudioPosition = playingStreamer.Position()
2020-01-22 22:54:55 +00:00
}
speaker.Unlock()
2020-01-22 22:54:55 +00:00
}