#!/bin/bash
set -e

command -v sudo > /dev/null && exec SUDO='sudo'
command -v doas > /dev/null && exec SUDO='doas'

CUR_LIGHT="$(set-light "$@")"

SCREENS="$($SUDO ddcutil detect | awk '$1 == "Display" {print $2}')"

for i in $SCREENS; do
    $SUDO ddcutil -d "$i" setvcp 10 "$CUR_LIGHT"
done
