add playing/paused status
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
37adfa721e
commit
196f1cf14e
|
@ -5,6 +5,7 @@ import (
|
|||
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetMetadata(metadata string) string {
|
||||
|
@ -26,12 +27,29 @@ func GetArtist() string {
|
|||
return GetMetadata("xesam:artist")
|
||||
}
|
||||
|
||||
func GetStatus() string {
|
||||
output, _ := exec.Command("playerctl", "-p", "spotify", "status").Output()
|
||||
|
||||
return strings.Trim(string(output), "\n")
|
||||
}
|
||||
|
||||
func main() {
|
||||
status := GetStatus()
|
||||
title := GetTitle()
|
||||
artist := GetArtist()
|
||||
stmt := ""
|
||||
|
||||
if title == "" {
|
||||
if status == "Not available" {
|
||||
return
|
||||
} else if status == "Paused" {
|
||||
stmt = r.TextWithPadding(r.FontAwesome("\uf04c"), r.FB{
|
||||
Background: r.Color("black3"),
|
||||
})
|
||||
} else if status == "Playing" {
|
||||
stmt = r.TextWithPadding(r.FontAwesome("\uf04b"), r.FB{
|
||||
Foreground: r.Color("green"),
|
||||
Background: r.Color("black3"),
|
||||
})
|
||||
}
|
||||
|
||||
label := r.TextWithPadding(artist, r.FB{
|
||||
|
@ -49,7 +67,7 @@ func main() {
|
|||
}
|
||||
|
||||
options := r.NewBlockOptions()
|
||||
options.FullText = fmt.Sprintf("%s%s", label, value)
|
||||
options.FullText = fmt.Sprintf("%s%s%s", stmt, label, value)
|
||||
block := r.Block("spotify", options)
|
||||
|
||||
fmt.Println(block)
|
||||
|
|
Loading…
Reference in New Issue