[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
This commit is contained in:
parent
87714f12ee
commit
188ee36780
4 changed files with 53 additions and 1 deletions
46
bumblebee/modules/redshift.py
Normal file
46
bumblebee/modules/redshift.py
Normal file
|
@ -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
|
BIN
screenshots/redshift.png
Normal file
BIN
screenshots/redshift.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -52,5 +52,8 @@
|
|||
},
|
||||
"xrandr": {
|
||||
"on": { "prefix": " off "}, "off": { "prefix": " on "}
|
||||
},
|
||||
"redshift": {
|
||||
"day": { "prefix": "day" }, "night": { "prefix": "night" }, "transition": { "prefix": "trans" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,9 @@
|
|||
"activated": {"prefix": " " }, "deactivated": { "prefix": " " }
|
||||
},
|
||||
"xrandr": {
|
||||
"on": { "prefix": " "}, "off": { "prefix": " "}
|
||||
"on": { "prefix": " "}, "off": { "prefix": " " }
|
||||
},
|
||||
"redshift": {
|
||||
"day": { "prefix": "" }, "night": { "prefix": "" }, "transition": { "prefix": "" }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue