diff --git a/main.go b/main.go index 87d2fb8..5e54623 100644 --- a/main.go +++ b/main.go @@ -68,7 +68,7 @@ func isInMusicFolder(fp string, musicFolders []string) bool { home, _ := os.UserHomeDir() folder = strings.Replace(folder, "~", home, 1) } - + if !filepath.IsAbs(folder) { home, _ := os.UserHomeDir() folder = filepath.Join(home, folder) @@ -76,7 +76,7 @@ func isInMusicFolder(fp string, musicFolders []string) bool { folder = filepath.Clean(folder) filePath := filepath.Clean(fp) - + if strings.HasPrefix(filePath, folder) { return true } @@ -87,7 +87,7 @@ func isInMusicFolder(fp string, musicFolders []string) bool { func main() { var connected bool var lastSong string - config, _:= config.GetConfig() + config, _ := config.GetConfig() for { if _, err := os.Stat(SOCKET_PATH); err == nil { if !connected { @@ -122,6 +122,10 @@ func main() { } } else { fmt.Printf("✗ Connection broken, restart mpv to reconnect: %v\n", err) + if connected { + client.Logout() + connected = false + } } time.Sleep(5 * time.Second)