mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Initial Implementation for Nerd Icons
This commit is contained in:
@@ -16,6 +16,33 @@ import (
|
||||
var (
|
||||
state *spotify.PlayerState
|
||||
ctrackId spotify.ID
|
||||
devices = map[string]string{
|
||||
"computer": "",
|
||||
"tablet": "",
|
||||
"smartphone": "",
|
||||
"speaker": "",
|
||||
"tv": "",
|
||||
"avr": "",
|
||||
"stb": "",
|
||||
"audio_dongle": "",
|
||||
"game_console": "",
|
||||
"cast_video": "",
|
||||
"cast_audio": "",
|
||||
"automobile": "",
|
||||
}
|
||||
playIcons = map[bool]string{
|
||||
true: "",
|
||||
false: "",
|
||||
}
|
||||
shuffleIcons = map[bool]string{
|
||||
true: "",
|
||||
false: "",
|
||||
}
|
||||
repeatIcons = map[string]string{
|
||||
"track": "",
|
||||
"off": "",
|
||||
"context": "",
|
||||
}
|
||||
)
|
||||
|
||||
// ProgressBar is a two-lined Box. First line is the BarTitle
|
||||
@@ -142,24 +169,60 @@ func progressRoutine() {
|
||||
}()
|
||||
}
|
||||
|
||||
func progressFunc() (string, string, string, float64) {
|
||||
percentage := 0.0
|
||||
barTitle := " - "
|
||||
barText := "---:---"
|
||||
barTopTitle := "[]"
|
||||
playing := "Paused"
|
||||
func deviceIcon(d spotify.PlayerDevice) string {
|
||||
if val, ok := devices[strings.ToLower(d.Type)]; cfg.UseNerdIcons && ok {
|
||||
return val
|
||||
}
|
||||
return "Device:"
|
||||
}
|
||||
|
||||
func topTitle(playing, shuffle bool, repeat string, device spotify.PlayerDevice) (
|
||||
playState, deviceIcn, deviceName, shuffleState, repeatState string) {
|
||||
|
||||
icon := ""
|
||||
playState = "Paused"
|
||||
shuffleState = fmt.Sprintf("%t", shuffle)
|
||||
|
||||
if playing {
|
||||
playState = "Playing"
|
||||
}
|
||||
|
||||
if cfg.UseNerdIcons {
|
||||
icon = playIcons[playing]
|
||||
icon += " "
|
||||
repeat = repeatIcons[repeat]
|
||||
shuffleState = shuffleIcons[shuffle]
|
||||
}
|
||||
|
||||
playState = icon + playState
|
||||
deviceIcn = deviceIcon(device)
|
||||
deviceName = device.Name
|
||||
repeatState = repeat
|
||||
return
|
||||
}
|
||||
|
||||
func progressFunc() (barTitle, barTopTitle, barText string, percentage float64) {
|
||||
percentage = 0
|
||||
barTitle = " - "
|
||||
barText = "---:---"
|
||||
barTopTitle = "[]"
|
||||
if state != nil {
|
||||
if state.Playing {
|
||||
playing = "Playing"
|
||||
}
|
||||
barTopTitle = fmt.Sprintf("[%s Device: %s Shuffle: %t Repeat: %s]", playing, state.Device.Name, state.ShuffleState, state.RepeatState)
|
||||
barTopTitle = fmt.Sprintf("[ %s %s %s Shuffle: %s Repeat: %s ]",
|
||||
wrap(
|
||||
topTitle(
|
||||
state.Playing,
|
||||
state.ShuffleState,
|
||||
state.RepeatState,
|
||||
state.Device))...)
|
||||
if state.Item != nil {
|
||||
barTitle = fmt.Sprintf("%s%s[-:-:-] - %s%s",
|
||||
cfg.Colors.PBarTrack.String(), state.Item.Name,
|
||||
cfg.Colors.PBarArtist.String(), artistName(state.Item.Artists))
|
||||
barText = utils.StrTime(float64(state.Progress/1000)) + "/" + utils.StrTime(float64(state.Item.Duration/1000))
|
||||
barText = utils.StrTime(float64(state.Progress/1000)) +
|
||||
"/" +
|
||||
utils.StrTime(float64(state.Item.Duration/1000))
|
||||
percentage = (float64(state.Progress) / float64(state.Item.Duration)) * 100
|
||||
}
|
||||
}
|
||||
return barTitle, barTopTitle, barText, percentage
|
||||
return
|
||||
}
|
||||
|
||||
@@ -127,3 +127,7 @@ func artistName(s []spotify.SimpleArtist) string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func wrap(args ...interface{}) []interface{} {
|
||||
return args
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user