oh-my-posh/src/segment_spotify.go

52 lines
1.1 KiB
Go
Raw Normal View History

2019-03-13 04:14:30 -07:00
package main
import "oh-my-posh/environment"
2019-03-13 04:14:30 -07:00
type spotify struct {
2022-01-22 10:46:56 -08:00
props Properties
env environment.Environment
2022-01-22 10:46:56 -08:00
MusicPlayer
}
type MusicPlayer struct {
Status string
Artist string
Track string
Icon string
2019-03-13 04:14:30 -07:00
}
const (
// PlayingIcon indicates a song is playing
2019-03-13 04:14:30 -07:00
PlayingIcon Property = "playing_icon"
// PausedIcon indicates a song is paused
2019-03-13 04:14:30 -07:00
PausedIcon Property = "paused_icon"
// StoppedIcon indicates a song is stopped
2020-11-04 23:56:12 -08:00
StoppedIcon Property = "stopped_icon"
2022-01-22 10:46:56 -08:00
playing = "playing"
stopped = "stopped"
paused = "paused"
2019-03-13 04:14:30 -07:00
)
func (s *spotify) template() string {
return "{{ .Icon }}{{ if ne .Status \"stopped\" }}{{ .Artist }} - {{ .Track }}{{ end }}"
2022-01-22 10:46:56 -08:00
}
2022-01-22 10:46:56 -08:00
func (s *spotify) resolveIcon() {
switch s.Status {
case stopped:
2020-11-04 23:56:12 -08:00
// in this case, no artist or track info
2022-01-22 10:46:56 -08:00
s.Icon = s.props.getString(StoppedIcon, "\uF04D ")
case paused:
s.Icon = s.props.getString(PausedIcon, "\uF8E3 ")
case playing:
s.Icon = s.props.getString(PlayingIcon, "\uE602 ")
2019-03-13 04:14:30 -07:00
}
}
func (s *spotify) init(props Properties, env environment.Environment) {
2019-03-13 04:14:30 -07:00
s.props = props
s.env = env
}