summaryrefslogtreecommitdiff
path: root/statusbar.go
diff options
context:
space:
mode:
Diffstat (limited to 'statusbar.go')
-rw-r--r--statusbar.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/statusbar.go b/statusbar.go
index a12c2ce..7cbbf18 100644
--- a/statusbar.go
+++ b/statusbar.go
@@ -19,7 +19,11 @@ type MusicPlayer interface {
status() int
}
-type MPD struct{}
+type MPD struct{
+ Host string
+ Port int
+}
+
type MOCP struct{}
type Config struct {
@@ -48,6 +52,8 @@ type MusicConfig struct {
LabelPaused string `toml:"labelpaused"`
LabelStopped string `toml:"labelstopped"`
Type string
+ Host string
+ Port int
}
type ClockConfig struct {
@@ -135,7 +141,7 @@ func clock(format string) string {
}
func (mpd MPD) nowPlaying() string {
- cmd := exec.Command("mpc", "current")
+ cmd := exec.Command("mpc", "-h", mpd.Host, "-p", strconv.Itoa(mpd.Port), "current")
out, err := cmd.Output()
if err != nil {
panic(err)
@@ -147,7 +153,7 @@ func (mpd MPD) nowPlaying() string {
// Returns 0 if playing, 1 if paused and 2 otherwise
func (mpd MPD) status() int {
- cmd := exec.Command("mpc", "status")
+ cmd := exec.Command("mpc", "-h", mpd.Host, "-p", strconv.Itoa(mpd.Port), "status")
out, err := cmd.Output()
if err != nil {
return -1
@@ -221,7 +227,15 @@ func buildMusic(config MusicConfig) string {
var player MusicPlayer
switch config.Type {
case "mpd":
- player = MPD{}
+ host := config.Host
+ if host == "" {
+ host = "127.0.0.1"
+ }
+ port := config.Port
+ if port == 0 {
+ port = 6600
+ }
+ player = MPD{Host: host, Port: port}
case "mocp":
player = MOCP{}
default: