Skip to content

Commit

Permalink
Add cmus player indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
aonemd committed Mar 18, 2018
1 parent befd350 commit 4ee02ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions components/cmus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"fmt"
"os/exec"
"regexp"
"strings"
)

func main() {
response, _ := exec.Command("cmus-remote", "-Q").Output()

artistPattern, _ := regexp.Compile("tag artist [a-zA-Z0-9_ ]+")
titlePattern, _ := regexp.Compile("tag title [a-zA-Z0-9_ ]+")

artist := strings.Trim(artistPattern.FindString(string(response)), "tag artist")
title := strings.Trim(titlePattern.FindString(string(response)), "tag title")

if artist != "" && title != "" {
fmt.Println(fmt.Sprintf("%s - %s", artist, title))
}
}
5 changes: 5 additions & 0 deletions onpar.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ func main() {
volumeLevel := NewComponent("components/volume_level", 1)
darkSkyWeather := NewComponent("components/dark_sky_weather", 600)
keyboardLayout := NewComponent("components/keyboard_layout", 1)
cmus := NewComponent("components/cmus", 1)
// Initialize new components here ...

go dateTime.Run()
go batteryLevel.Run()
go volumeLevel.Run()
go darkSkyWeather.Run()
go keyboardLayout.Run()
go cmus.Run()
// Call new components Run() here ...

for {
Expand All @@ -59,12 +61,15 @@ func main() {
go batteryLevel.Run()
case volumeLevel.Output = <-volumeLevel.Channel:
go volumeLevel.Run()
case cmus.Output = <-cmus.Channel:
go cmus.Run()
// Call new components Run() here ...
}

status = []string{
"",
// Add new components here ...
cmus.Output,
keyboardLayout.Output,
darkSkyWeather.Output,
volumeLevel.Output,
Expand Down

0 comments on commit 4ee02ce

Please sign in to comment.