oh-my-posh/segment_spotify.go

46 lines
1 KiB
Go
Raw Normal View History

2019-03-13 04:14:30 -07:00
package main
import (
"fmt"
)
type spotify struct {
props *properties
env environmentInfo
status string
artist string
track string
}
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"
// TrackSeparator is put between the artist and the track
2019-03-13 04:14:30 -07:00
TrackSeparator Property = "track_separator"
)
func (s *spotify) string() string {
icon := ""
switch s.status {
2020-11-04 23:56:12 -08:00
case "stopped":
// in this case, no artist or track info
icon = s.props.getString(StoppedIcon, "\uF04D ")
return icon
2019-03-13 04:14:30 -07:00
case "paused":
2020-10-16 07:07:12 -07:00
icon = s.props.getString(PausedIcon, "\uF8E3 ")
2019-03-13 04:14:30 -07:00
case "playing":
2020-10-16 07:07:12 -07:00
icon = s.props.getString(PlayingIcon, "\uE602 ")
2019-03-13 04:14:30 -07:00
}
separator := s.props.getString(TrackSeparator, " - ")
return fmt.Sprintf("%s%s%s%s", icon, s.artist, separator, s.track)
}
func (s *spotify) init(props *properties, env environmentInfo) {
s.props = props
s.env = env
}