diff --git a/i3pystatus/pianobar.py b/i3pystatus/pianobar.py new file mode 100644 index 0000000..eb33525 --- /dev/null +++ b/i3pystatus/pianobar.py @@ -0,0 +1,48 @@ +from i3pystatus import IntervalModule + +class Pianobar(IntervalModule): + """ + Shows the title and artist name of the current music + + In pianobar config file must be setted the fifo and event_command options + (see man pianobar for more information) + + Mouse events: + - Left click play/pauses + - Right click plays next song + - Scroll up/down changes volume + """ + + settings = ( + ("format"), + ("songfile", "File generated by pianobar eventcmd"), + ("ctlfile", "Pianobar fifo file"), + ("color", "The color of the text"), + ) + format = "{songtitle} -- {songartist}" + required = ("format", "songfile", "ctlfile") + color = "#FFFFFF" + + def run(self): + with open(self.songfile, "r") as f: + contents = f.readlines() + + sn = contents[0].strip() + sa = contents[1].strip() + + self.output = { + "full_text": self.format.format(songtitle=sn, songartist=sa), + "color": self.color + } + + def on_leftclick(self): + open(self.ctlfile,"w").write("p") + + def on_rightclick(self): + open(self.ctlfile,"w").write("n") + + def on_upscroll(self): + open(self.ctlfile,"w").write(")") + + def on_downscroll(self): + open(self.ctlfile,"w").write("(")