fix(spotify): adjust incorrect erorr check

This commit is contained in:
Jan De Dobbeleer 2024-03-05 12:49:56 +01:00 committed by Jan De Dobbeleer
parent 21df976c2f
commit ae73c1dad5

View file

@ -3,24 +3,28 @@
package segments package segments
func (s *Spotify) Enabled() bool { func (s *Spotify) Enabled() bool {
var err error
// Check if running // Check if running
running := s.runAppleScriptCommand("application \"Spotify\" is running") running := s.runAppleScriptCommand("application \"Spotify\" is running")
if running == "false" || running == "" { if running == "false" || running == "" {
s.Status = stopped s.Status = stopped
return false return false
} }
s.Status = s.runAppleScriptCommand("tell application \"Spotify\" to player state as string") s.Status = s.runAppleScriptCommand("tell application \"Spotify\" to player state as string")
if err != nil {
if len(s.Status) == 0 {
s.Status = stopped s.Status = stopped
return false return false
} }
if s.Status == stopped { if s.Status == stopped {
return false return false
} }
s.Artist = s.runAppleScriptCommand("tell application \"Spotify\" to artist of current track as string") s.Artist = s.runAppleScriptCommand("tell application \"Spotify\" to artist of current track as string")
s.Track = s.runAppleScriptCommand("tell application \"Spotify\" to name of current track as string") s.Track = s.runAppleScriptCommand("tell application \"Spotify\" to name of current track as string")
s.resolveIcon() s.resolveIcon()
return true return true
} }