mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-14 23:14:05 -08:00
29 lines
672 B
Go
29 lines
672 B
Go
// +build windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
func (s *spotify) enabled() bool {
|
|
// search for spotify window to retrieve the title
|
|
// Can be either "Spotify xxx" or the song name "Candlemass - Spellbreaker"
|
|
spotifyWindowTitle, err := s.env.getWindowTitle("spotify.exe", "^(Spotify.*)|(.*\\s-\\s.*)$")
|
|
if err != nil {
|
|
return false
|
|
}
|
|
|
|
if !strings.Contains(spotifyWindowTitle, " - ") {
|
|
s.status = "stopped"
|
|
return false
|
|
}
|
|
|
|
infos := strings.Split(spotifyWindowTitle, " - ")
|
|
s.artist = infos[0]
|
|
// remove first element and concat others(a song can contains also a " - ")
|
|
s.track = strings.Join(infos[1:], " - ")
|
|
s.status = "playing"
|
|
return true
|
|
}
|