-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotebook_backlight_v0.1.sh
More file actions
executable file
·38 lines (26 loc) · 967 Bytes
/
notebook_backlight_v0.1.sh
File metadata and controls
executable file
·38 lines (26 loc) · 967 Bytes
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
#! /bin/bash
#date >> /home/larce/Pictures/web_shot/log
colors=$(fswebcam -d /dev/video0 -r 1024x768 -q - | convert - -resize 1x1 txt:- | sed -n 2p | sed 's/.*srgb(\([0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*\))/\1/')
IFS=',' read -ra bright_array <<< "$colors"
battery=$(acpi)
IFS=',' read -ra batt_array <<< "$battery"
battery=$(echo ${batt_array[1]} | sed 's/%//')
ac_stat=$(acpi -a)
IFS=':' read -ra ac_array <<< "$ac_stat"
if [[ ${ac_array[1]} == " off-line" ]]; then
add_bright=150
else
add_bright=200
fi
min_batt=40
if [[ $battery -lt $min_batt ]]; then
bright=$(echo "100.0/765.0*(${bright_array[1]:4} + $add_bright / $min_batt * $battery)" | bc -l | sed 's/\([0-9]*\).*/\1/')
else
bright=$(echo "100.0/765.0*(${bright_array[1]:4} + $add_bright)" | bc -l | sed 's/\([0-9]*\).*/\1/')
fi
# Check for minimal brightness value
if [[ $bright -lt 10 ]]; then
bright=15
fi
xbacklight -set "$bright"% -time 1000
xbacklight -get | sed 's/\([0-9]*\).*/\1%/'