-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathddc-brightness
executable file
·37 lines (33 loc) · 1.07 KB
/
ddc-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
#!/bin/bash
set -e
# Description:
# sets the brightess (or contrast) on all monitors defined in $ddc_displays
# Note:
# Requires ddcutil i2c-tools packages
#sudo modprobe i2c-dev
if [ "$1" = "detect" ]; then
ddcutil detect | grep Display -A 1 | awk '{print $3}' | tr '\n' ' '
echo ''
fi
_set_vcp() {
# 1 display, 2 feature, 3 value
sudo ddcutil --sleep-multiplier=0.1 --noverify --skip-ddc-checks --display="$1" setvcp "$2" "$3"
}
#ddc_displays=$(for display in $(cat $XDG_CONFIG_HOME/ddc_displays); do echo $display; done)
#ddc_displays="/dev/i2c-7 /dev/i2c-8 /dev/i2c-4"
# To get your config do:
# echo $(sudo ddcutil detect | grep Display -A 1 | awk '{print $3}' | tr '\n' ' ' ; echo '') > $XDG_CONFIG_HOME/ddc_displays
#for display in $ddc_displays; do
# bus=${display: -1}
# [ -z "$bus" ] && continue
# sudo ddcutil --bus=$bus setvcp 10 $1 &
# [ -z "$2" ] && continue
# sleep 0.5 && sudo ddcutil --bus=$bus setvcp 12 $2 &
#done
displays="1"
for display in $displays; do
_set_vcp "$display" 10 "$1"
[ -z "$2" ] && continue
_set_vcp "$display" 12 "$2"
done
printf "\n"