From 530b9f2d8849f2b7f04fab72bfabaa81523f3706 Mon Sep 17 00:00:00 2001 From: Lennart Braun Date: Fri, 26 Feb 2016 15:34:38 +0100 Subject: [PATCH] Add mpd password support --- i3pystatus/mpd.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/i3pystatus/mpd.py b/i3pystatus/mpd.py index 1aed61a..feeb178 100644 --- a/i3pystatus/mpd.py +++ b/i3pystatus/mpd.py @@ -39,10 +39,12 @@ class MPD(IntervalModule): ("max_len", "Defines max length for the hole string, if exceeding fields specefied in truncate_fields are truncated equaly. If truncated, ellipsis are appended as indicator. It's applied *after* max_field_len. Value of 0 disables this."), ("truncate_fields", "fields that will be truncated if exceeding max_field_len or max_len."), ("hide_inactive", "Hides status information when MPD is not running"), + ("password", "A password for access to MPD. (This is sent in cleartext to the server.)"), ) host = "localhost" port = 6600 + password = None s = None format = "{title} {status}" status = { @@ -71,6 +73,9 @@ class MPD(IntervalModule): self.s.connect(self.host) sock = self.s sock.recv(8192) + if self.password is not None: + sock.send('password "{}"\n'.format(self.password).encode()) + sock.recv(8192) sock.send((command + "\n").encode("utf-8")) try: reply = sock.recv(16384).decode("utf-8")