-
Notifications
You must be signed in to change notification settings - Fork 0
/
brightness.py
59 lines (45 loc) · 1.12 KB
/
brightness.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
##NOTE: Install "brightnessctl"
from Bafr import Bafr
from Grid import Grid
import os
def increase(value=3):
cmd = "brightnessctl"
flags = ["s", f"+{value}%"]
bafr = Bafr("brightness.increase")
bafr.set_cmd(cmd)
bafr.set_cmd_flags(flags)
if not bafr.run():
bafr.eecho(end="\n")
bafr.exit()
def decrease(value=3):
cmd = "brightnessctl"
flags = ["s", f"{value}%-"]
bafr = Bafr("brightness.decrease")
bafr.set_cmd(cmd)
bafr.set_cmd_flags(flags)
if not bafr.run():
bafr.eecho(end="\n")
bafr.exit()
def brightness_parser(raw):
g = Grid(raw)
for i in g:
if "Current" in i:
return i[3][1:-1]
def query():
cmd = "brightnessctl"
flags = ["i"]
bafr = Bafr("brightness")
bafr.set_cmd(cmd)
bafr.set_cmd_flags(flags)
bafr.set_parser(brightness_parser)
if not bafr.run():
bafr.eecho(end="\n")
bafr.exit()
bafr.echo(end="\n")
def brightness(params=None):
button = os.getenv("button")
if button == "4":
increase()
elif button == "5":
decrease()
query()