From 4840362030a4a1b6c33cffee62d991fa121354b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Rieger=20Lucchese?= Date: Sun, 2 Nov 2014 13:21:04 -0200 Subject: [PATCH 1/3] Add pianobar module --- i3pystatus/pianobar.py | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 i3pystatus/pianobar.py 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("(") From 4fe4408736268e3a2c8437cca70625b4fc1a4a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Rieger=20Lucchese?= Date: Sun, 2 Nov 2014 14:14:43 -0200 Subject: [PATCH 2/3] Fix blank lines and whitespaces --- i3pystatus/pianobar.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/i3pystatus/pianobar.py b/i3pystatus/pianobar.py index eb33525..a05b94b 100644 --- a/i3pystatus/pianobar.py +++ b/i3pystatus/pianobar.py @@ -1,10 +1,11 @@ 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 + In pianobar config file must be setted the fifo and event_command options (see man pianobar for more information) Mouse events: @@ -25,7 +26,7 @@ class Pianobar(IntervalModule): def run(self): with open(self.songfile, "r") as f: - contents = f.readlines() + contents = f.readlines() sn = contents[0].strip() sa = contents[1].strip() @@ -36,13 +37,13 @@ class Pianobar(IntervalModule): } def on_leftclick(self): - open(self.ctlfile,"w").write("p") + open(self.ctlfile, "w").write("p") def on_rightclick(self): - open(self.ctlfile,"w").write("n") + open(self.ctlfile, "w").write("n") def on_upscroll(self): - open(self.ctlfile,"w").write(")") + open(self.ctlfile, "w").write(")") def on_downscroll(self): - open(self.ctlfile,"w").write("(") + open(self.ctlfile, "w").write("(") From 97c9cb7e80e72f13befc4cc7effb11402b238df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Rieger=20Lucchese?= Date: Sun, 2 Nov 2014 15:23:00 -0200 Subject: [PATCH 3/3] Add optional event_cmd bash file into the docs --- i3pystatus/pianobar.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/i3pystatus/pianobar.py b/i3pystatus/pianobar.py index a05b94b..5314ee9 100644 --- a/i3pystatus/pianobar.py +++ b/i3pystatus/pianobar.py @@ -8,6 +8,9 @@ class Pianobar(IntervalModule): In pianobar config file must be setted the fifo and event_command options (see man pianobar for more information) + For the event_cmd use: + https://github.com/jlucchese/pianobar/blob/master/contrib/pianobar-song-i3.sh + Mouse events: - Left click play/pauses - Right click plays next song