From f0f3e8fd8089279dda9570a79a7eed0201b2895e Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 30 Dec 2022 18:14:56 -0300 Subject: Fix: xbrightness: misc fixes --- xbrightness | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xbrightness b/xbrightness index c15c131..f86f72f 100755 --- a/xbrightness +++ b/xbrightness @@ -1,18 +1,23 @@ #!/usr/bin/env bash # Change the screen brightness. # See the output of "$0 -h" for details. +# +# Script obtained at https://unix.stackexchange.com/questions/61256/how-to-change-lcd-intensivity-brightness +# Minor fixes by rhatto # Exit immediately on each error and unset variable; # see: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ #set -Eeuo pipefail set -Eeu +# This script is locale-dependent +export LC_ALL=C + APP_NAME="Screen Brightness Changer" cmd=${1:-get} bl_dir=/sys/class/backlight/intel_backlight function print_help() { - script_name="$(basename "$0")" echo "${APP_NAME} - Allows to change the screen brightness." echo "It may do so using the hardware backlight or through software manipulation of pixel values sent to the screen." @@ -146,7 +151,7 @@ then mth_bare=true elif which xrandr > /dev/null 2>&1 then - echo "Using xrandr (software) ..." + #echo "Using xrandr (software) ..." # This has no prerequisite; it should always work. # This method only manipulates the pixel values sent to the screen, imitating more/less brightness (software). mth_xrandr=true @@ -167,7 +172,7 @@ then val_cur=$(printf "%.3f" "$(awk "BEGIN { print(1.0 * $val_cur_abs / $val_max) }")") elif $mth_xrandr then - val_cur=$(xrandr --verbose | grep -i "brightness" | sed -e 's|.*: ||') + val_cur=$(xrandr --verbose | grep -i "brightness" | sed -e 's|.*: ||' | head -1) else >&2 echo "No low-level-method chosen!" exit 1 @@ -195,8 +200,11 @@ then echo -n "$val_new_abs" | tee "$bl_dir/brightness"> /dev/null elif $mth_xrandr then - display=$(xrandr -q | grep " connected" | sed -e 's| .*||') - xrandr --output "$display" --brightness "$val_new" + displays=$(xrandr -q | grep " connected" | sed -e 's| .*||') + + for display in $displays; do + xrandr --output "$display" --brightness "$val_new" + done else >&2 echo "No low-level-method chosen!" exit 1 -- cgit v1.2.3