3.15: mpd, add status and leftclick for play/pause
This commit is contained in:
parent
c5153ae12a
commit
eb44638b87
17
README.md
17
README.md
@ -112,6 +112,7 @@ __Settings:__
|
|||||||
* `alert_format_body` — (default: `Battery {battery_ident} has only {percentage:.2f}% ({remaining_hm}) remaining!`)
|
* `alert_format_body` — (default: `Battery {battery_ident} has only {percentage:.2f}% ({remaining_hm}) remaining!`)
|
||||||
* `alert_percentage` — (default: `10`)
|
* `alert_percentage` — (default: `10`)
|
||||||
* `path` — (default: `None`)
|
* `path` — (default: `None`)
|
||||||
|
* `status` — A dictionary mapping ('DIS', 'CHR', 'FULL') to alternative names (default: `{'FULL': 'FULL', 'CHR': 'CHR', 'DIS': 'DIS'}`)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -285,12 +286,14 @@ Available formatters:
|
|||||||
* playtime_s (Playtime, seconds)
|
* playtime_s (Playtime, seconds)
|
||||||
* 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
|
||||||
|
|
||||||
|
|
||||||
__Settings:__
|
__Settings:__
|
||||||
|
|
||||||
* `port` — MPD port (default: `6600`)
|
* `port` — MPD port (default: `6600`)
|
||||||
* `format` — (default: `{title} [{playtime_h}:{playtime_m}:{playtime_s}]`)
|
* `format` — (default: `{title} {status}`)
|
||||||
|
* `status` — Dictionary mapping pause, play and stop to output (default: `{'pause': '▷', 'play': '▶', 'stop': '◾'}`)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -446,18 +449,6 @@ __Settings:__
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
### xrandr
|
|
||||||
|
|
||||||
|
|
||||||
Do Not Publish, private hack of it's own
|
|
||||||
|
|
||||||
|
|
||||||
__Settings:__
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
|
@ -16,17 +16,24 @@ class MPD(IntervalModule):
|
|||||||
* playtime_s (Playtime, seconds)
|
* playtime_s (Playtime, seconds)
|
||||||
* 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
|
||||||
"""
|
"""
|
||||||
interval = 1
|
interval = 1
|
||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
("port", "MPD port"),
|
("port", "MPD port"),
|
||||||
"format",
|
"format",
|
||||||
|
("status", "Dictionary mapping pause, play and stop to output")
|
||||||
)
|
)
|
||||||
|
|
||||||
port = 6600
|
port = 6600
|
||||||
|
|
||||||
format = "{title} [{playtime_h}:{playtime_m}:{playtime_s}]"
|
format = "{title} {status}"
|
||||||
|
status = {
|
||||||
|
"pause": "▷",
|
||||||
|
"play": "▶",
|
||||||
|
"stop": "◾",
|
||||||
|
}
|
||||||
|
|
||||||
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"))
|
||||||
@ -46,6 +53,7 @@ class MPD(IntervalModule):
|
|||||||
status = self._mpd_command(s, "status")
|
status = self._mpd_command(s, "status")
|
||||||
fdict["pos"] = int(status["song"])+1
|
fdict["pos"] = int(status["song"])+1
|
||||||
fdict["len"] = int(status["playlistlength"])
|
fdict["len"] = int(status["playlistlength"])
|
||||||
|
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["Title"]
|
||||||
@ -60,3 +68,9 @@ class MPD(IntervalModule):
|
|||||||
self.output = {
|
self.output = {
|
||||||
"full_text": self.format.format(**fdict).strip(),
|
"full_text": self.format.format(**fdict).strip(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def on_leftclick(self):
|
||||||
|
with socket.create_connection(("localhost", self.port)) as s:
|
||||||
|
s.recv(8192)
|
||||||
|
|
||||||
|
self._mpd_command(s, "pause %i" % (0 if self._mpd_command(s, "status")["state"] == "pause" else 1))
|
||||||
|
12
setup.py
12
setup.py
@ -3,7 +3,7 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
setup(name="i3pystatus",
|
setup(name="i3pystatus",
|
||||||
version="3.14",
|
version="3.15",
|
||||||
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",
|
||||||
@ -25,14 +25,4 @@ setup(name="i3pystatus",
|
|||||||
entry_points={
|
entry_points={
|
||||||
"console_scripts": ["i3pystatus = i3pystatus:main"],
|
"console_scripts": ["i3pystatus = i3pystatus:main"],
|
||||||
},
|
},
|
||||||
|
|
||||||
# install_requires=[
|
|
||||||
# "gobject",
|
|
||||||
# ],
|
|
||||||
# install_requires=[
|
|
||||||
# "Jinja2",
|
|
||||||
# "lxml",
|
|
||||||
# "markdown",
|
|
||||||
# "PyRSS2Gen",
|
|
||||||
# ]
|
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user