Skip to main content
deleted 10 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242
xrandr --verbose | sed '/.*Br[^01]*\(.*\)Br/!d;s/.* /\1;q'/;q'

That deletes all lines before the first occurrence of the Br string. When it finds one it then removes everything up to and including the last <space> from the line but the first 0 or 1 and all that follows before immediately quitting the input. So all that remains in a case of 100% brightness is, for instance:

echo "<$(xrandr --verbose | sed '/.*Br[^01]*\(.*\)Br/!d;s/.* /\1/;q')>"
<1.0>
xrandr --verbose | sed '/.*Br[^01]*\(.*\)/!d;s//\1;q'

That deletes all lines before the first occurrence of the Br string then removes everything from the line but the first 0 or 1 and all that follows before immediately quitting the input. So all that remains in a case of 100% brightness is, for instance:

echo "<$(xrandr --verbose | sed '/.*Br[^01]*\(.*\)/!d;s//\1/;q')>"
<1.0>
xrandr --verbose | sed '/Br/!d;s/.* //;q'

That deletes all lines before the first occurrence of the Br string. When it finds one it then removes everything up to and including the last <space> from the line before immediately quitting the input. So all that remains in a case of 100% brightness is, for instance:

echo "<$(xrandr --verbose | sed '/Br/!d;s/.* //;q')>"
<1.0>
added 539 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

In the same vein as many other answers you can quit the input with sed as soon as you encounter a Brightness string like:

xrandr --verbose | sed '/.*Br[^01]*\(.*\)/!d;s//\1;q'

That deletes all lines before the first occurrence of the Br string then removes everything from the line but the first 0 or 1 and all that follows before immediately quitting the input. So all that remains in a case of 100% brightness is, for instance:

echo "<$(xrandr --verbose | sed '/.*Br[^01]*\(.*\)/!d;s//\1/;q')>"
<1.0>

It would be far better though if you could get a valid EDID on your output and directly affect its backlight with the following tool:

It would be far better though if you could get a valid EDID on your output and directly affect its backlight with the following tool:

In the same vein as many other answers you can quit the input with sed as soon as you encounter a Brightness string like:

xrandr --verbose | sed '/.*Br[^01]*\(.*\)/!d;s//\1;q'

That deletes all lines before the first occurrence of the Br string then removes everything from the line but the first 0 or 1 and all that follows before immediately quitting the input. So all that remains in a case of 100% brightness is, for instance:

echo "<$(xrandr --verbose | sed '/.*Br[^01]*\(.*\)/!d;s//\1/;q')>"
<1.0>

It would be far better though if you could get a valid EDID on your output and directly affect its backlight with the following tool:

added 1244 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

Of course, if your hardware does not support it, this is not an option. So you must resort to the software adjustment as you have been doing:

man xrandr 2>/dev/null |
grep '^ *--brightness' -A8
   --brightness brightness
          Multiply the gamma values on the  crtc  cur‐
          rently  attached  to the output to specified
          floating value. Useful for overly bright  or
          overly  dim  outputs.   However,  this  is a
          software only modification, if your hardware
          has  support  to actually change the bright‐
          ness, you will probably prefer to use xback‐
          light.

It would appear that the brightness settting is nothing more than a multiplier for the RGB gamma values of your display. As such, it might make more sense - or, at least, it may be easier - if you instead directly affected that with xgamma.

xgamma
-> Red  1.000, Green  1.000, Blue  1.000

xgamma -gamma .7
-> Red  1.000, Green  1.000, Blue  1.000
<- Red  0.700, Green  0.700, Blue  0.700

It would be far better though if you could get a valid EDID on your output and directly affect its backlight with the following tool:

Of course, if your hardware does not support it, this is not an option. So you must resort to the software adjustment as you have been doing:

man xrandr 2>/dev/null |
grep '^ *--brightness' -A8
   --brightness brightness
          Multiply the gamma values on the  crtc  cur‐
          rently  attached  to the output to specified
          floating value. Useful for overly bright  or
          overly  dim  outputs.   However,  this  is a
          software only modification, if your hardware
          has  support  to actually change the bright‐
          ness, you will probably prefer to use xback‐
          light.

It would appear that the brightness settting is nothing more than a multiplier for the RGB gamma values of your display. As such, it might make more sense - or, at least, it may be easier - if you instead directly affected that with xgamma.

xgamma
-> Red  1.000, Green  1.000, Blue  1.000

xgamma -gamma .7
-> Red  1.000, Green  1.000, Blue  1.000
<- Red  0.700, Green  0.700, Blue  0.700

It would be far better though if you could get a valid EDID on your output and directly affect its backlight with the following tool:

Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242
Loading