mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
28 lines
770 B
Go
28 lines
770 B
Go
// +build darwin
|
|
|
|
package main
|
|
|
|
func (s *spotify) enabled() bool {
|
|
var err error
|
|
// Check if running
|
|
running := s.runAppleScriptCommand("application \"Spotify\" is running")
|
|
if running == "false" || running == "" {
|
|
return false
|
|
}
|
|
s.status = s.runAppleScriptCommand("tell application \"Spotify\" to player state as string")
|
|
if err != nil {
|
|
return false
|
|
}
|
|
if s.status == "stopped" {
|
|
return false
|
|
}
|
|
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")
|
|
return true
|
|
}
|
|
|
|
func (s *spotify) runAppleScriptCommand(command string) string {
|
|
val, _ := s.env.runCommand("osascript", "-e", command)
|
|
return val
|
|
}
|