aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2022-12-30 18:14:56 -0300
committerSilvio Rhatto <rhatto@riseup.net>2022-12-30 18:14:56 -0300
commitf0f3e8fd8089279dda9570a79a7eed0201b2895e (patch)
tree1d85d2c80e5d18ce48d5576a0936e2896b9e78f1
parentf5a9c48e0296eac54f3779e985ce577bb49f212c (diff)
downloadutils-x11-f0f3e8fd8089279dda9570a79a7eed0201b2895e.tar.gz
utils-x11-f0f3e8fd8089279dda9570a79a7eed0201b2895e.tar.bz2
Fix: xbrightness: misc fixes
-rwxr-xr-xxbrightness18
1 files 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