From b7f290e0fa1c358961c91121b033ea5a06f7d46c Mon Sep 17 00:00:00 2001 From: Martin Sekera Date: Sat, 18 Jan 2025 18:46:18 +0100 Subject: [PATCH] brightness-i2c: change storage from env var to file --- bin/brightness-i2c | 8 +++++++- lib/prompt-init | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/brightness-i2c b/bin/brightness-i2c index f82f28b..6afa28d 100755 --- a/bin/brightness-i2c +++ b/bin/brightness-i2c @@ -2,8 +2,14 @@ OPERATOR="${1}" AMOUNT="${2}" +F="$XDG_RUNTIME_DIR/over/monitors-i2c" -BUSES=(${(s/:/)OVER_ENV_MONITORS_I2C}) +if [[ ! -e "$F" ]]; then + exit 1 +fi + +MONITORS_I2C=$(cat $XDG_RUNTIME_DIR/over/monitors-i2c) +BUSES=(${(s/:/)MONITORS_I2C}) for BUS in ${BUSES} do diff --git a/lib/prompt-init b/lib/prompt-init index 760d539..ae8a5ea 100755 --- a/lib/prompt-init +++ b/lib/prompt-init @@ -8,7 +8,8 @@ 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} + mkdir -p $XDG_RUNTIME_DIR/over + echo ${(j|:|)I2C_IDS} > $XDG_RUNTIME_DIR/over/monitors-i2c fi if [[ -a "$OVER_PROMPT_CFG" ]]; then