This is probably a better way to handle file.File-based modules.
This commit is contained in:
parent
7d0193ccc1
commit
2196c27ad4
19
README.md
19
README.md
@ -59,7 +59,24 @@ This class shows a clock
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
### file
|
### file.Backlight
|
||||||
|
|
||||||
|
|
||||||
|
Screen backlight info
|
||||||
|
|
||||||
|
Available formatters:
|
||||||
|
* brightness
|
||||||
|
* max_brightness
|
||||||
|
* percentage
|
||||||
|
|
||||||
|
|
||||||
|
* `format` — format string (default: `{brightness}/{max_brightness}`)
|
||||||
|
* `backlight` — backlight, see `/sys/class/backlight/` (default: `acpi_video0`)
|
||||||
|
* `color` — (default: `#FFFFFF`)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### file.File
|
||||||
|
|
||||||
|
|
||||||
Rip information from text files
|
Rip information from text files
|
||||||
|
@ -47,9 +47,9 @@ class File(IntervalModule):
|
|||||||
"color": self.color
|
"color": self.color
|
||||||
}
|
}
|
||||||
|
|
||||||
def backlight(backlight="acpi_video0", format="{brightness}/{max_brightness}"):
|
class Backlight(File):
|
||||||
"""
|
"""
|
||||||
Backlight info template
|
Screen backlight info
|
||||||
|
|
||||||
Available formatters:
|
Available formatters:
|
||||||
* brightness
|
* brightness
|
||||||
@ -57,15 +57,27 @@ def backlight(backlight="acpi_video0", format="{brightness}/{max_brightness}"):
|
|||||||
* percentage
|
* percentage
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return File(
|
settings = (
|
||||||
base_path="/sys/class/backlight/{backlight}/".format(backlight=backlight),
|
("format", "format string"),
|
||||||
|
("backlight", "backlight, see `/sys/class/backlight/`"),
|
||||||
|
"color",
|
||||||
|
)
|
||||||
|
required = ()
|
||||||
|
|
||||||
|
backlight="acpi_video0"
|
||||||
|
format="{brightness}/{max_brightness}"
|
||||||
|
|
||||||
|
interval=1
|
||||||
|
base_path = "/sys/class/backlight/{backlight}/"
|
||||||
components={
|
components={
|
||||||
"brightness": (int, "brightness"),
|
"brightness": (int, "brightness"),
|
||||||
"max_brightness": (int, "max_brightness"),
|
"max_brightness": (int, "max_brightness"),
|
||||||
},
|
}
|
||||||
transforms={
|
transforms={
|
||||||
"percentage": lambda cdict: (cdict["brightness"] / cdict["max_brightness"]) * 100,
|
"percentage": lambda cdict: (cdict["brightness"] / cdict["max_brightness"]) * 100,
|
||||||
},
|
}
|
||||||
format="{brightness}/{max_brightness}",
|
|
||||||
interval=1
|
def init(self):
|
||||||
)
|
self.base_path = self.base_path.format(backlight=self.backlight)
|
||||||
|
|
||||||
|
super().init()
|
||||||
|
Loading…
Reference in New Issue
Block a user