backlight module
Probably I'll discard these as soon as I come up with a nice generic way of reading multiple files, converting values etc.
This commit is contained in:
parent
bde56dfdec
commit
a5bcf9bfa2
14
README.md
14
README.md
@ -35,6 +35,18 @@ as you like.
|
||||
## Modules
|
||||
|
||||
|
||||
### backlight
|
||||
|
||||
|
||||
Shows backlight brightness
|
||||
|
||||
|
||||
* format — format string used for output. {brightness}, {max_brightness}, {percentage} are available (default: {brightness}/{max_brightness})
|
||||
* backlight — backlight. See /sys/class/backlight/ (default: acpi_video0)
|
||||
* color — (default: #FFFFFF)
|
||||
|
||||
|
||||
|
||||
### battery
|
||||
|
||||
|
||||
@ -43,6 +55,7 @@ battery status
|
||||
|
||||
|
||||
* battery_ident — (default: BAT0)
|
||||
* format — (default: {status} {remaining})
|
||||
|
||||
|
||||
|
||||
@ -79,6 +92,7 @@ The `backends` setting determines the backends to use. Currently available are:
|
||||
* color_unread — (default: #ff0000)
|
||||
* format — (default: {unread} new email)
|
||||
* format_plural — (default: {unread} new emails)
|
||||
* hide_if_null — Don't output anything if there are no new mails (default: True)
|
||||
|
||||
|
||||
Currently available backends are:
|
||||
|
31
i3pystatus/backlight.py
Normal file
31
i3pystatus/backlight.py
Normal file
@ -0,0 +1,31 @@
|
||||
from i3pystatus import IntervalModule
|
||||
|
||||
class Backlight(IntervalModule):
|
||||
"""
|
||||
Shows backlight brightness
|
||||
"""
|
||||
|
||||
settings = (
|
||||
("format", "format string used for output. {brightness}, {max_brightness}, {percentage} are available"),
|
||||
("backlight", "backlight. See /sys/class/backlight/"),
|
||||
"color",
|
||||
)
|
||||
format = "{brightness}/{max_brightness}"
|
||||
color = "#FFFFFF"
|
||||
backlight = "acpi_video0"
|
||||
|
||||
def init(self):
|
||||
self.base_path = "/sys/class/backlight/{backlight}".format(backlight=self.backlight)
|
||||
|
||||
with open("{base_path}/max_brightness".format(base_path=self.base_path), "r") as f:
|
||||
self.max_brightness = int(f.read())
|
||||
|
||||
def run(self):
|
||||
with open("{base_path}/brightness".format(base_path=self.base_path), "r") as f:
|
||||
brightness = int(f.read())
|
||||
|
||||
percentage = (brightness / self.max_brightness) * 100
|
||||
self.output = {
|
||||
"full_text" : self.format.format(brightness=brightness, max_brightness=self.max_brightness, percentage=percentage),
|
||||
"color": self.color,
|
||||
}
|
@ -23,7 +23,8 @@ class Mail(IntervalModule):
|
||||
|
||||
settings = (
|
||||
("backends", "List of backends (instances of i3pystatus.mail.xxx)"),
|
||||
"color", "color_unread", "format", "format_plural"
|
||||
"color", "color_unread", "format", "format_plural",
|
||||
("hide_if_null", "Don't output anything if there are no new mails"),
|
||||
)
|
||||
required = ("backends",)
|
||||
|
||||
@ -31,6 +32,7 @@ class Mail(IntervalModule):
|
||||
color_unread ="#ff0000"
|
||||
format = "{unread} new email"
|
||||
format_plural = "{unread} new emails"
|
||||
hide_if_null = True
|
||||
|
||||
def init(self):
|
||||
for backend in self.backends:
|
||||
@ -42,6 +44,9 @@ class Mail(IntervalModule):
|
||||
if not unread:
|
||||
color = self.color
|
||||
urgent = "false"
|
||||
if self.hide_if_null:
|
||||
self.output = None
|
||||
return
|
||||
else:
|
||||
color = self.color_unread
|
||||
urgent = "true"
|
||||
|
Loading…
Reference in New Issue
Block a user