3.16: MPD: stop state bugfix, mute/unmute on rightclick
Yes, I currently just increase the minor version number on every fix
This commit is contained in:
parent
eb44638b87
commit
5ee67aaefd
@ -17,6 +17,8 @@ class MPD(IntervalModule):
|
|||||||
* pos (Position of current song in playlist, one-based)
|
* pos (Position of current song in playlist, one-based)
|
||||||
* len (Length of current playlist)
|
* len (Length of current playlist)
|
||||||
* status
|
* status
|
||||||
|
|
||||||
|
Left click on the module play/pauses, right click (un)mutes.
|
||||||
"""
|
"""
|
||||||
interval = 1
|
interval = 1
|
||||||
|
|
||||||
@ -27,7 +29,6 @@ class MPD(IntervalModule):
|
|||||||
)
|
)
|
||||||
|
|
||||||
port = 6600
|
port = 6600
|
||||||
|
|
||||||
format = "{title} {status}"
|
format = "{title} {status}"
|
||||||
status = {
|
status = {
|
||||||
"pause": "▷",
|
"pause": "▷",
|
||||||
@ -35,10 +36,11 @@ class MPD(IntervalModule):
|
|||||||
"stop": "◾",
|
"stop": "◾",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vol = 100
|
||||||
|
|
||||||
def _mpd_command(self, sock, command):
|
def _mpd_command(self, sock, command):
|
||||||
sock.send((command + "\n").encode("utf-8"))
|
sock.send((command + "\n").encode("utf-8"))
|
||||||
reply = sock.recv(16384)
|
reply = sock.recv(16384).decode("utf-8")
|
||||||
reply = reply.decode("utf-8")
|
|
||||||
replylines = reply.split("\n")[:-2]
|
replylines = reply.split("\n")[:-2]
|
||||||
|
|
||||||
return dict(
|
return dict(
|
||||||
@ -56,7 +58,7 @@ class MPD(IntervalModule):
|
|||||||
fdict["status"] = self.status[status["state"]]
|
fdict["status"] = self.status[status["state"]]
|
||||||
|
|
||||||
currentsong = self._mpd_command(s, "currentsong")
|
currentsong = self._mpd_command(s, "currentsong")
|
||||||
fdict["title"] = currentsong["Title"]
|
fdict["title"] = currentsong.get("Title", "")
|
||||||
fdict["album"] = currentsong.get("Album", "")
|
fdict["album"] = currentsong.get("Album", "")
|
||||||
fdict["artist"] = currentsong.get("Artist", "")
|
fdict["artist"] = currentsong.get("Artist", "")
|
||||||
|
|
||||||
@ -74,3 +76,14 @@ class MPD(IntervalModule):
|
|||||||
s.recv(8192)
|
s.recv(8192)
|
||||||
|
|
||||||
self._mpd_command(s, "pause %i" % (0 if self._mpd_command(s, "status")["state"] == "pause" else 1))
|
self._mpd_command(s, "pause %i" % (0 if self._mpd_command(s, "status")["state"] == "pause" else 1))
|
||||||
|
|
||||||
|
def on_rightclick(self):
|
||||||
|
with socket.create_connection(("localhost", self.port)) as s:
|
||||||
|
s.recv(8192)
|
||||||
|
|
||||||
|
vol = int(self._mpd_command(s, "status")["volume"])
|
||||||
|
if vol == 0:
|
||||||
|
self._mpd_command(s, "setvol %i" % self.vol)
|
||||||
|
else:
|
||||||
|
self.vol = vol
|
||||||
|
self._mpd_command(s, "setvol 0")
|
||||||
|
2
setup.py
2
setup.py
@ -3,7 +3,7 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
setup(name="i3pystatus",
|
setup(name="i3pystatus",
|
||||||
version="3.15",
|
version="3.16",
|
||||||
description="Like i3status, this generates status line for i3bar / i3wm",
|
description="Like i3status, this generates status line for i3bar / i3wm",
|
||||||
url="http://github.com/enkore/i3pystatus",
|
url="http://github.com/enkore/i3pystatus",
|
||||||
license="MIT",
|
license="MIT",
|
||||||
|
Loading…
Reference in New Issue
Block a user