From b6d069b90a71982d1f6ebc982794ef98ec4c6748 Mon Sep 17 00:00:00 2001 From: roku Date: Sat, 1 Feb 2025 11:03:08 +0100 Subject: [PATCH] brightness-i2c: fix log spam on denied access, move monitor detection from prompt to zshrc --- etc/zsh/zshrc | 12 ++++++++++++ lib/prompt-init | 7 ------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index c6f0b8c..df92806 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -218,3 +218,15 @@ do break fi done + +# detect monitors for bin/brightness-i2c +which ddcutil > /dev/null +if (( $? == 0 )); then + local I2C_IDS=($(ddcutil detect --terse 2>/dev/null | grep "I2C bus" | sed "s/^.*-//")) + # will be empty if no monitors support ddc or if we don't have I2C access via ACL + if (( ${#I2C_IDS[@]} > 0)); then + mkdir -p $XDG_RUNTIME_DIR/over + echo ${(j|:|)I2C_IDS} >! $XDG_RUNTIME_DIR/over/monitors-i2c + fi +fi + diff --git a/lib/prompt-init b/lib/prompt-init index 3bf7c01..edfe0d1 100755 --- a/lib/prompt-init +++ b/lib/prompt-init @@ -5,13 +5,6 @@ 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/^.*-//")) - mkdir -p $XDG_RUNTIME_DIR/over - echo ${(j|:|)I2C_IDS} >! $XDG_RUNTIME_DIR/over/monitors-i2c -fi - if [[ -a "$OVER_PROMPT_CFG" ]]; then source "$OVER_PROMPT_CFG" fi