forked from JanDeDobbeleer/oh-my-posh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsegment_spotify.go
45 lines (40 loc) · 1.03 KB
/
segment_spotify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
)
type spotify struct {
props *properties
env environmentInfo
status string
artist string
track string
}
const (
//PlayingIcon indicates a song is playing
PlayingIcon Property = "playing_icon"
//PausedIcon indicates a song is paused
PausedIcon Property = "paused_icon"
//StoppedIcon indicates a song is stopped
StoppedIcon Property = "stopped_icon"
//TrackSeparator is put between the artist and the track
TrackSeparator Property = "track_separator"
)
func (s *spotify) string() string {
icon := ""
switch s.status {
case "stopped":
// in this case, no artist or track info
icon = s.props.getString(StoppedIcon, "\uF04D ")
return icon
case "paused":
icon = s.props.getString(PausedIcon, "\uF8E3 ")
case "playing":
icon = s.props.getString(PlayingIcon, "\uE602 ")
}
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
}