2019-03-13 04:14:30 -07:00
|
|
|
package main
|
|
|
|
|
2022-01-26 01:23:18 -08:00
|
|
|
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
|
2022-01-26 01:23:18 -08:00
|
|
|
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 (
|
2020-11-12 00:43:32 -08:00
|
|
|
// PlayingIcon indicates a song is playing
|
2019-03-13 04:14:30 -07:00
|
|
|
PlayingIcon Property = "playing_icon"
|
2020-11-12 00:43:32 -08:00
|
|
|
// PausedIcon indicates a song is paused
|
2019-03-13 04:14:30 -07:00
|
|
|
PausedIcon Property = "paused_icon"
|
2020-11-12 00:43:32 -08:00
|
|
|
// 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
|
|
|
)
|
|
|
|
|
2022-01-23 12:37:51 -08: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-23 12:37:51 -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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-26 01:23:18 -08:00
|
|
|
func (s *spotify) init(props Properties, env environment.Environment) {
|
2019-03-13 04:14:30 -07:00
|
|
|
s.props = props
|
|
|
|
s.env = env
|
|
|
|
}
|