Tagged: Brightness, Display
- This topic has 18 replies, 8 voices, and was last updated Jan 20-9:40 pm by blur13.
-
AuthorPosts
-
January 19, 2022 at 6:09 pm #75563Member
blur13
::Thats a great script!
I had a similar idea and simply used an alias
alias bright=“xrandr –output HDMI-1 –brightness”bright 0.5 gives 50% brightness etc.
Your script is of course much better since it works in the general case.
January 20, 2022 at 7:14 pm #75654MemberPPC
::I created a yad GUI for the script:
#!/bin/bash set_brightness(){ local bright local output bright="$*" if ! [[ "${bright}" =~ ^[0-9]+(.[0-9]+)?$ ]]; then echo "Passed brightness value [${bright}] is not a float - won't do [return]" return fi output="$(xrandr | grep '\<connected\>' | awk ' { print $1 } ')" # Grep for a complete word if [ "$(echo "${output}" | wc -l)" -gt 1 ]; then echo "Too many monitors connected - won't do [return]" return fi real_current_brightness=$(xrandr --verbose --current | grep "Brightness:" | cut -d":" -f2) QTY=10 yad_current_brightness=$(echo "scale=2; $real_current_brightness*$QTY" | bc ) xrandr --output "${output}" --brightness "${bright}" } real_current_brightness=$(xrandr --verbose --current | grep "Brightness:" | cut -d":" -f2) QTY=10 yad_current_brightness=$(echo "scale=2; $real_current_brightness*$QTY" | bc ) echo $yad_current_brightness choice=$(yad --undecorated --no-escape --center --image="/usr/share/icons/papirus-antix/symbolic/status/display-brightness-high-symbolic.png" --title="Luce" --geometry=800x100+280+200 --scale --value=$yad_current_brightness --min-value="1" --max-value="10" --step="1" --button="OK") new_value1=$(echo "scale=2; $choice/10" | bc ) new_value=$(echo 0$new_value1) case $? in 1) choice=$real_current_brightness ;; 252) echo 'Aborting'; exit 1;; esac #if (( $new_value=> 0.1 )) then; set_brightness $new_value #fiJanuary 20, 2022 at 8:06 pm #75656MemberRobin
::Hello PPC , Your new script works fine with a 32 bit notebook running on antiX 19 Live persistent.
But there is actually no need to restrict it to a single monitor only.
brightness correction works fine when feeding the xrandr command for each connected output individually, like:
xrandr --output VGA-2 --brightness 0.8 xrandr --output VGA-1 --brightness 0.5So you simply can add a counter in order to display the needed number of sliders in yad:
yad --form --field=Display1:SCL --field=Display2:SCL --field=Display3:SCLand for only two monitors it would be:
yad --form --field=Display1:SCL --field=Display2:SCLYou can put the terms –field=DisplayN:SCL into variables, and if the variable is empty, the respective slider won’t get displayed.
You will have to put the actual display names into these variables on runtime, but I’m sure you can achieve this easily.
Another hint:
I just noticed, xrandr wouldn’t actually set brightness on my machine like the hardware buttons do by dimming the backlight, but merely letting the backlight at 100% and overlay a semitransparent black layer over the complete screen instead. This is a quite power consuming way of dimming a screeen… But I have to admit I also didn’t find a solution to access the backlight brightness setting directly.Windows is like a submarine. Open a window and serious problems will start.
January 20, 2022 at 9:40 pm #75658Member
blur13
::Someone else who created a scrip and added permanence between reboots:
http://sandipbgt.com/2015/10/01/control-screen-brightness-from-commandline-in-ubuntu/
Robin,
You are right! Thanks for pointing that out. Checked the manpage for xrandr:
“–brightness brightness
Multiply the gamma values on the crtc currently attached to the output to specified floating
value. Useful for overly bright or overly dim outputs. However, this is a software only modifi‐
cation, if your hardware has support to actually change the brightness, you will probably prefer
to use xbacklight.” -
AuthorPosts
- You must be logged in to reply to this topic.