forked from mdeff/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrightness
executable file
·39 lines (32 loc) · 1.24 KB
/
brightness
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
#!/usr/bin/env python
import os
import subprocess
import sys
value = sys.argv[1]
command = ["brightnessctl", "--exponent=4", "set", value]
for device in os.listdir("/sys/class/backlight/"):
cmd = command + [f"--device={device}"]
print(' '.join(cmd))
subprocess.run(cmd)
# How it works:
# * /sys/class/backlight/ddcci1 is created when the ddcci_backlight module is loaded.
# * Same interface as the laptop backlight (/sys/class/backlight/intel_backlight).
# * The module is loaded by the windows manager when the user switches to a workspace that has an external monitor.
# Manually reload the modules:
# 1. sudo modprobe -r ddcci_backlight ddcci
# 2. sudo modprobe ddcci
# 3. lsmod | grep ddc
# pros and cons of alternatives:
# * ddcutil: too complicated to compute percent values and increases with exponent
# * ddcci-driver-linux-dkms: no hotplug detection, module must be reloaded
# ddcutil alternative:
# command = ["ddcutil", "setvcp", "10"]
# command.extend(value)
# faster (measured with --stats) but might fail
# command += ["--sleep-multiplier", ".2"]
# much faster to select by bus than display
# command += ["--bus"]
# for display in range(1, 4):
# cmd = command + [str(display)]
# print(' '.join(cmd))
# #subprocess.run(cmd)