43 lines
1.2 KiB
Bash
Executable File
43 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
DIR="/sys/class/backlight"
|
|
|
|
[[ "${BLOCK_INSTANCE}" == "color" ]] && MODE="color" || MODE="bw"
|
|
|
|
if [[ -d "$DIR/acpi_video0" ]]; then
|
|
DIR="$DIR/acpi_video0"
|
|
elif [[ -d "$DIR/intel_backlight" ]]; then
|
|
DIR="$DIR/intel_backlight"
|
|
else
|
|
echo " no backlight "
|
|
echo "n/a"
|
|
exit 33
|
|
fi
|
|
|
|
cat "$DIR/brightness" "$DIR/max_brightness" | gawk -v MODE="$MODE" '
|
|
NR==1 { current_brightness = $1 }
|
|
NR==2 { max_brightness = $1 }
|
|
END {
|
|
relative_brightness = ( current_brightness / max_brightness ) * 100
|
|
printf("%d%\n", relative_brightness)
|
|
printf("%d\n", relative_brightness)
|
|
if (MODE == "color") {
|
|
if (relative_brightness < 50) {
|
|
print("#04B431\n")
|
|
} else if (relative_brightness < 60) {
|
|
print("#A8FF00\n")
|
|
} else if (relative_brightness < 70) {
|
|
print("#FFF600\n")
|
|
} else if (relative_brightness < 80) {
|
|
print("#FFAE00\n")
|
|
} else if (relative_brightness < 90) {
|
|
print("#FF0000\n")
|
|
} else {
|
|
exit 33
|
|
}
|
|
} else {
|
|
printf("\n")
|
|
}
|
|
}
|
|
'
|