nixos-config/modules/workspace/i3blocks/scripts/music.nix

19 lines
756 B
Nix
Raw Normal View History

2020-02-17 17:00:59 +04:00
{ python3, playerctl, iconfont, ...}: ''
#!${python3}/bin/python
from subprocess import getoutput, call
from os import environ
status = getoutput("${playerctl}/bin/playerctl status")
if "BLOCK_BUTTON" in environ:
BLOCK_BUTTON = environ["BLOCK_BUTTON"]
if BLOCK_BUTTON == "1": call(["${playerctl}/bin/playerctl", "play-pause"])
if BLOCK_BUTTON == "2": call(["${playerctl}/bin/playerctl", "stop"])
if BLOCK_BUTTON == "3": call(["${playerctl}/bin/playerctl", "next"])
2020-07-27 01:16:19 +04:00
if status == "Paused" or status == "Playing":
text = getoutput("${playerctl}/bin/playerctl metadata title")[:20:]
icon = ""
else:
text = ""
icon = ""
2020-02-17 17:00:59 +04:00
print("<span font='${iconfont}'>%s</span> %s" % (icon, text.replace('&', '&amp;')))
''