-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkblight.py
executable file
·54 lines (47 loc) · 1.06 KB
/
kblight.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
#!/usr/bin/python
import math
import subprocess
import sys
# Custom Ramp
increments = [
0,
2,
5,
10,
20,
30,
40,
50,
60,
70,
80,
90,
100,
]
try:
direction = sys.argv[1]
except:
direction = 'show'
# Get Current
popen = subprocess.Popen(('/usr/bin/xbacklight'), stdout=subprocess.PIPE)
popen.wait()
backlight = int(round(float(popen.stdout.read().strip())))
if direction == 'show':
print(backlight)
sys.exit()
if direction == 'up':
if backlight == 100:
sys.exit()
while len(increments):
x = increments.pop(0)
if x > backlight:
popen = subprocess.Popen(('/usr/bin/xbacklight', '-set', '%s' % x))
break
elif direction == 'down':
if backlight == 0:
sys.exit()
while len(increments):
x = increments.pop()
if x < backlight:
popen = subprocess.Popen(('/usr/bin/xbacklight', '-set', '%s' % x))
break