Added a config parser
Add a config.yml/config.toml file to $HOME/.config/goMP/ so that user configurations are read.
This commit is contained in:
7
main.go
7
main.go
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/fhs/gompd/mpd"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var Volume int64
|
||||
@@ -16,9 +17,9 @@ var Repeat bool
|
||||
var InsidePlaylist bool = true
|
||||
|
||||
func main() {
|
||||
|
||||
readConfig()
|
||||
// Connect to MPD server
|
||||
conn, err := mpd.Dial("tcp", "localhost:6600")
|
||||
conn, err := mpd.Dial("tcp", "localhost:"+viper.GetString("MPD_PORT"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
@@ -27,7 +28,7 @@ func main() {
|
||||
r := newRenderer()
|
||||
c, _ := conn.CurrentSong()
|
||||
if len(c) != 0 {
|
||||
r.Start(DBDIR + c["file"])
|
||||
r.Start(viper.GetString("MUSIC_DIRECTORY") + c["file"])
|
||||
} else {
|
||||
r.Start("stop")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user