From 38ee4f180960350aff07498e4277b269a401cee6 Mon Sep 17 00:00:00 2001 From: Martin Sekera Date: Sat, 18 Jan 2025 00:51:30 +0100 Subject: [PATCH] add brightness control for I2C monitors --- bin/brightness-i2c | 11 +++++++++++ lib/prompt-init | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100755 bin/brightness-i2c diff --git a/bin/brightness-i2c b/bin/brightness-i2c new file mode 100755 index 0000000..f82f28b --- /dev/null +++ b/bin/brightness-i2c @@ -0,0 +1,11 @@ +#! /bin/zsh + +OPERATOR="${1}" +AMOUNT="${2}" + +BUSES=(${(s/:/)OVER_ENV_MONITORS_I2C}) + +for BUS in ${BUSES} +do + ddcutil --skip-ddc-checks --noverify --verbose --bus=${BUS} setvcp 0x10 "${OPERATOR}" "${AMOUNT}" +done diff --git a/lib/prompt-init b/lib/prompt-init index edfe0d1..760d539 100755 --- a/lib/prompt-init +++ b/lib/prompt-init @@ -5,6 +5,12 @@ zmodload zsh/datetime OVER_PROMPT_CFG="/etc/over/env/prompt.cfg" OVER_PROMPT_TITLE="" +which ddcutil > /dev/null +if [[ $? -eq 0 ]]; then + local I2C_IDS=($(ddcutil detect --terse | grep "I2C bus" | sed "s/^.*-//")) + export OVER_ENV_MONITORS_I2C=${(j|:|)I2C_IDS} +fi + if [[ -a "$OVER_PROMPT_CFG" ]]; then source "$OVER_PROMPT_CFG" fi