-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpceg_backlight.sh
executable file
·21 lines (17 loc) · 1.39 KB
/
vpceg_backlight.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
printf '#!/bin/bash\n' > /usr/sbin/writeintelbacklight.sh
printf '\n' >> /usr/sbin/writeintelbacklight.sh
printf 'intelmaxbrightness=`cat /sys/class/backlight/intel_backlight/max_brightness`\n' >> /usr/sbin/writeintelbacklight.sh
printf 'acpimaxbrightness=`cat /sys/class/backlight/acpi_video0/max_brightness`\n' >> /usr/sbin/writeintelbacklight.sh
printf 'scale=`expr $intelmaxbrightness / $acpimaxbrightness`\n' >> /usr/sbin/writeintelbacklight.sh
printf 'acpibrightness=`cat /sys/class/backlight/acpi_video0/brightness`\n' >> /usr/sbin/writeintelbacklight.sh
printf 'newintelbrightness=`expr $acpibrightness \* $scale`\n' >> /usr/sbin/writeintelbacklight.sh
printf 'curintelbrightness=`cat /sys/class/backlight/intel_backlight/actual_brightness`\n' >> /usr/sbin/writeintelbacklight.sh
printf 'if [ "$newintelbrightness" -ne "$curintelbrightness" ]\n' >> /usr/sbin/writeintelbacklight.sh
printf 'then\n' >> /usr/sbin/writeintelbacklight.sh
printf ' echo $newintelbrightness >> /sys/class/backlight/intel_backlight/brightness\n' >> /usr/sbin/writeintelbacklight.sh
printf 'fi\n' >> /usr/sbin/writeintelbacklight.sh
printf 'exit 0\n' >> /usr/sbin/writeintelbacklight.sh
printf '\n' >> /usr/sbin/writeintelbacklight.sh
chmod +x /usr/sbin/writeintelbacklight.sh
printf 'ACTION=="change", SUBSYSTEM=="backlight", RUN+="/usr/sbin/writeintelbacklight.sh"\n' > /etc/udev/rules.d/99-writeintelbacklight.rules