Created
February 19, 2020 21:52
-
-
Save AnyTimeTraveler/237de901e1584783046a3860b0875ec9 to your computer and use it in GitHub Desktop.
A module for i3pystatus to show if the Teestube at the student houseing Dukegat is open or closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from i3pystatus import IntervalModule | |
import requests | |
class Teestube(IntervalModule): | |
""" | |
Shows if the Teestube is open or closed | |
Requires requests | |
""" | |
open_text = "TS Open" | |
closed_text = "TS closed" | |
open_color = "#00FF00" | |
closed_color = "#FF0000" | |
settings = ( | |
("open_text", "text when TS is open"), | |
("closed_text", "text when TS is closed"), | |
("open_color", "color when TS is open"), | |
("closed_color", "color when TS is closed"), | |
) | |
def run(self): | |
r = requests.get(url='https://www.dukegat.de/api.php?q=/heartbeat/lamp') | |
if r.json() and r.json()['heartbeat']: | |
self.output = { | |
"full_text": self.open_text, | |
"color": self.open_color, | |
} | |
else: | |
self.output = { | |
"full_text": self.closed_text, | |
"color": self.closed_color, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment