diff --git a/bumblebee/modules/redshift.py b/bumblebee/modules/redshift.py new file mode 100644 index 0000000..2fd1dfb --- /dev/null +++ b/bumblebee/modules/redshift.py @@ -0,0 +1,46 @@ +# pylint: disable=C0111,R0903 + +"""Displays the current color temperature of redshift + +Requires the following executable: + * redshift +""" + +import bumblebee.input +import bumblebee.output +import bumblebee.engine + +class Module(bumblebee.engine.Module): + def __init__(self, engine, config): + super(Module, self).__init__(engine, config, + bumblebee.output.Widget(full_text=self.text) + ) + self._text = "" + self._state = "transition" + + def text(self, widget): + return "{}".format(self._text) + + def update(self, widgets): + result = bumblebee.util.execute("redshift -p") + + temp = "" + transition = "" + for line in result.split("\n"): + if "temperature" in line.lower(): + temp = line.split(" ")[2] + if "period" in line.lower(): + state = line.split(" ")[1].lower() + if "day" in state: + self._state = "day" + elif "night" in state: + self._state = "night" + else: + self._state = "transition" + transition = " ".join(line.split(" ")[2:]) + self._text = "{} {}".format(temp, transition) + + def state(self, widget): + return self._state + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/screenshots/redshift.png b/screenshots/redshift.png new file mode 100644 index 0000000..999328f Binary files /dev/null and b/screenshots/redshift.png differ diff --git a/themes/icons/ascii.json b/themes/icons/ascii.json index 613f133..de89921 100644 --- a/themes/icons/ascii.json +++ b/themes/icons/ascii.json @@ -52,5 +52,8 @@ }, "xrandr": { "on": { "prefix": " off "}, "off": { "prefix": " on "} + }, + "redshift": { + "day": { "prefix": "day" }, "night": { "prefix": "night" }, "transition": { "prefix": "trans" } } } diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index a8eda48..7322cf9 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -63,6 +63,9 @@ "activated": {"prefix": " " }, "deactivated": { "prefix": " " } }, "xrandr": { - "on": { "prefix": " "}, "off": { "prefix": " "} + "on": { "prefix": " "}, "off": { "prefix": " " } + }, + "redshift": { + "day": { "prefix": "" }, "night": { "prefix": "" }, "transition": { "prefix": "" } } }