-
Notifications
You must be signed in to change notification settings - Fork 892
feat: scripts - ddcutil script to handle brightness control for extern… #1771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…al monitors A new script based on the default brightnesscontrol.sh but using ddcutil to control the brightness of external monitors. The main issue is : DDC/CI protocol is slow
Tweaked comments and print_error
|
Good afternoon, I'm not a programmer at all, but I changed something in your script and it seems to work faster |
|
Yep, you're right, updated to implement a variable |
|
Sadly I can't test this one yet as my external monitor don't have ddc/ci, will try to find someone having that proto. |
|
but for some reason cant control it with scroll wheel over waybar though. just from terminal. is that also possible? @Melk0rr |
|
@Melk0rr Can I add this script in HyDE repo? |
Hi, yes no problem ! #!/usr/bin/bash
ScrDir=$(dirname "$(realpath "$0")")
source "$ScrDir/globalcontrol.sh"
monitorInfo=$(ddcutil detect)
mapfile monitors < <(echo "$monitorInfo" | grep "I2C bus:" | cut -s -f 2 -d :)
model=$(echo "$monitorInfo" | grep "Model:" | cut -s -f 2 -d : | head -n 1 | xargs)
print_error() {
cat <<"EOF"
./brightnesscontrol.sh <action>
...valid actions are...
i -- <i>ncrease brightness [+5%]
d -- <d>ecrease brightness [-5%]
s -- <s>et VALUE brightness [VALUE%]
g -- <g>et brightness
EOF
}
get_brightness() {
ddcutil getvcp 10 | awk -F 'current value = ' '{print $2}' | grep -o '[0-9]\+' | head -n 1
}
send_notification() {
brightness=$(get_brightness)
angle=$((((brightness + 2) / 5) * 5))
ico="$HOME/.config/dunst/icons/vol/vol-${angle}.svg"
notify-send -a "t2" -r 91190 -t 800 -i "${ico}" "Brightness ${brightness}" "${model}"
}
set_brightness() {
for v in "${monitors[@]}"; do
bus=$(echo "$v" | cut -s -f 2 -d -)
case $1 in
i)
ddcutil setvcp 10 + "$2" --bus="$bus"
;;
d)
ddcutil setvcp 10 - "$2" --bus="$bus"
;;
*)
ddcutil setvcp 10 "$2" --bus="$bus"
;;
esac
done
}
case $1 in
i)
currentBrightness=$(get_brightness)
if [[ "$currentBrightness" -lt 10 ]]; then
# Increase the brightness by 1% if less than 10%
set_brightness i 1
else
# Increase the brightness by 5% otherwise
set_brightness i 5
fi
send_notification
;;
d)
currentBrightness=$(get_brightness)
if [[ "$currentBrightness" -le 2 ]]; then
# Avoid 0% brightness
set_brightness s 2
elif [[ "$currentBrightness" -le 10 ]]; then
# Decrease the brightness by 1% if less than 10%
set_brightness d 1
else
# Decrease the brightness by 5% otherwise
set_brightness d 5
fi
send_notification
;;
s)
if [[ $2 -le 2 ]]; then
# Avoid 0% brightness
set_brightness s 2
else
set_brightness s "$2"
fi
send_notification
;;
g)
send_notification
;;
*)
print_error
;;
esac
|

A new script based on the default brightnesscontrol.sh but using ddcutil to control the brightness of external monitors.
The main issue is : DDC/CI protocol is slow
Pull Request
Description
Type of change
Please put an
xin the boxes that apply:Checklist
Please put an
xin the boxes that apply:Screenshots
Additional context