add support for MPD connects via AF_UNIX sockets
A port number equal to 0 now lets the mpd module interpret the host as a path to a socket.
This commit is contained in:
parent
3234897409
commit
45377b12c3
@ -31,7 +31,7 @@ class MPD(IntervalModule):
|
||||
|
||||
settings = (
|
||||
("host"),
|
||||
("port", "MPD port"),
|
||||
("port", "MPD port. If set to 0, host will we interpreted as a Unix socket."),
|
||||
("format", "formatp string"),
|
||||
("status", "Dictionary mapping pause, play and stop to output"),
|
||||
("color", "The color of the text"),
|
||||
@ -64,7 +64,11 @@ class MPD(IntervalModule):
|
||||
try:
|
||||
sock.send((command + "\n").encode("utf-8"))
|
||||
except Exception as e:
|
||||
if self.port != 0:
|
||||
self.s = socket.create_connection((self.host, self.port))
|
||||
else:
|
||||
self.s = socket.socket(family=socket.AF_UNIX)
|
||||
self.s.connect(self.host)
|
||||
sock = self.s
|
||||
sock.recv(8192)
|
||||
sock.send((command + "\n").encode("utf-8"))
|
||||
|
Loading…
Reference in New Issue
Block a user