From 188ee367807708369bc467adacf730f7b4a3cee1 Mon Sep 17 00:00:00 2001 From: Tobi-wan Kenobi Date: Sat, 21 Jan 2017 11:23:29 +0100 Subject: [PATCH] [modules] Add redshift module New module that shows the current state of redshift (day/night/transition) and, if in transition, also shows the day/night percentages. fixes #40 --- bumblebee/modules/redshift.py | 46 ++++++++++++++++++++++++++++++++ screenshots/redshift.png | Bin 0 -> 1325 bytes themes/icons/ascii.json | 3 +++ themes/icons/awesome-fonts.json | 5 +++- 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 bumblebee/modules/redshift.py create mode 100644 screenshots/redshift.png 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 0000000000000000000000000000000000000000..999328f62411baa2eb9867a6f08c81355c9c9d71 GIT binary patch literal 1325 zcmV+|1=9M7P);hj?zO0BN0 zwQE;62)l~5+wH>=>Gy5j2BV1`7?8d91h0^UtM+eSghE_?4jtnS4t%_ z^WU|0J(rR4c2#-p)f+Y(-?Ie(7>)w~f*@zhiZGk4p}proHVcDJ%S}mAX>}i8X&9P# zuxc>c9S(&?ceiig%j>rT=zjc!STc#|KG2s!UdJ$l$?Uo?o6Ttno=wCstfhZ&&1h=7 zH%zDbWhEziV!2dVAY=yyeAC>9+wJ?0qd<`U;rZ(FV>xxL-A42JHh22b;_nja>n|18 zUZ~+5Vr|DkCR;4l9Uq&K7&|aF>1Z@og&P;i zY3%F^WidUm03ba+rb3kab#v?1T(i%)!(cKub^ppwihW#wN~Y2Es7w*G#-Oadu-A1^QDr>*~v-nmQ=Rz$+thqmXtOe|8r{gmp{hx`N~I1n5|6Vk@czB#$#WU&ZAkZrCXl~R_MH9R4`db>lTTX8?Ux!xZDf`bBA3`S>r zL^=ZicX|h$x2f?lk{OvNmP<|D{X_zxLVR>Dhc{q{JvqXPVX`HaWLEat^WqQ|b4s>o z-7J<-p}}ufmKx0Kmv6QxwL160RwziXED$O+x^*j-92-@Zm)+7oxU{SV0J&O|$&C+V z2PriAe0~ZqCbGW08?)hivnXVeI5Vw(WZYmf+i+aItbJ81e5h2Z-Db#B98Qsl#6m%O zFq3gKjhmJb!;OwC%gfHsNb&dc)vp-`MkjV0H7{2X351f|%u=Bsgc*3N_ul=#rZ!J> zjh2Rzh>OCwG{^dX!NUen(y%}{^0ln*W~TzA)Q1ZypWeQIz6|b zR9`$(#SUcj-XFc&{~Is*FoW*bH8k?HeX}_CwR^GK9~@i7VF#T&F1mF67PcGk{|O=9 jf2H2vKVBSO9DC5;Z`#53zx_~B00000NkvXXu0mjfg4AvN literal 0 HcmV?d00001 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": "" } } }