14

I'm trying to play a game (Deus Ex) which I have to modify the brightness since it is very dark in my ambiance. The game has a "Brightness" setting, but lately it doesn't work. I tried to figure out how to change it and find out that xgamma do a similar effect with xgamma -gamma 5. But whenever I change it, the settings revert back after almost a second (so yeah, my screen light up then shuts down). How can I either, make the xgamma settings permanent (or persistent) or I have to use another tool?

My system is a desktop.

Seemsly xrandr --output DVI-0 --brightness 2 do the same, but still reverts back to 0 whenever I apply the settings.

Each time I try to change it the following output fill the Xorg.0.log file:

[ 14768.313] (II) RADEON(0): EDID vendor "HWP", prod id 9798
[ 14768.313] (II) RADEON(0): Using hsync ranges from config file
[ 14768.313] (II) RADEON(0): Using vrefresh ranges from config file
[ 14768.313] (II) RADEON(0): Printing DDC gathered Modelines:
[ 14768.313] (II) RADEON(0): Modeline "1024x768"x0.0   65.00  1024 1048 1184 1344  768 771 777 806 -hsync -vsync (48.4 kHz eP)
[ 14768.313] (II) RADEON(0): Modeline "800x600"x0.0   40.00  800 840 968 1056  600 601 605 628 +hsync +vsync (37.9 kHz e)
[ 14768.313] (II) RADEON(0): Modeline "640x480"x0.0   31.50  640 656 720 840  480 481 484 500 -hsync -vsync (37.5 kHz e)
[ 14768.313] (II) RADEON(0): Modeline "640x480"x0.0   31.50  640 664 704 832  480 489 492 520 -hsync -vsync (37.9 kHz e)
[ 14768.313] (II) RADEON(0): Modeline "640x480"x0.0   25.18  640 656 752 800  480 490 492 525 -hsync -vsync (31.5 kHz e)
[ 14768.313] (II) RADEON(0): Modeline "720x400"x0.0   28.32  720 738 846 900  400 412 414 449 -hsync +vsync (31.5 kHz e)
[ 14768.313] (II) RADEON(0): Modeline "1024x768"x0.0   78.75  1024 1040 1136 1312  768 769 772 800 +hsync +vsync (60.0 kHz e)
[ 14768.313] (II) RADEON(0): Modeline "1024x768"x0.0   75.00  1024 1048 1184 1328  768 771 777 806 -hsync -vsync (56.5 kHz e)
[ 14768.313] (II) RADEON(0): Modeline "832x624"x0.0   57.28  832 864 928 1152  624 625 628 667 -hsync -vsync (49.7 kHz e)
[ 14768.313] (II) RADEON(0): Modeline "800x600"x0.0   49.50  800 816 896 1056  600 601 604 625 +hsync +vsync (46.9 kHz e)
[ 14768.313] (II) RADEON(0): Modeline "800x600"x0.0   50.00  800 856 976 1040  600 637 643 666 +hsync +vsync (48.1 kHz e)

So, apparently my monitor gets redetected each time.

  • Your monitor doesn't have hardware controls for that? – jordanm Oct 26 '13 at 19:10
  • @jordanm yeah, those are maxed out. The screen isn't very bright to begin with. – Braiam Oct 26 '13 at 19:16
22

Silly me! I have xflux with fluxgui activated, each time I would like to modify the settings xflux will be in my way. All commands worked, just that xflux would revert it back.

Those who want to change their gamma/brightness:

Use xrandr to list your outputs:

$ xrandr
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
DVI-0 connected 1024x768+0+0 (normal left inverted right x axis y axis) 304mm x 228mm

As you can see my output is DVI-0 to change the brightness:

xrandr --output DVI-0 --brightness 2

To change the gamma:

xrandr --output DVI-0 --gamma 2:2:1
  • 3
    Is there an interactive gui for these xrandr settings? I can't fine one. – Fabio A. Feb 6 '17 at 13:40
  • @FabioA. If you haven't found a GUI yet you might want to post a new question on this site or Ask Ubuntu site. – WinEunuuchs2Unix Feb 4 '18 at 19:02
2

I was hoping there was some interactive program for adjusting xrandr's settings (gamma/brightness in particular), but couldn't find anything.

So I wrote this shell script which allows some interactive adjustment of brightness/gamma, as well as saving/restoring the settings.

Save the file to irandr.sh, do a chmod u+x irandr.sh to make it executable, and run as ./irandr.sh <outputname>.

The d/f/D/F/j/k/J/K keys adjust the brightness (d/f/D/F) or gamma (j/k/J/K) settings by steps of 5 (lower case) or 1 (upper case.)

  • s saves the settings to the dotfile
  • l loads the settings from the dotfile
  • r resets brightness/gamma to the defaults (1.0)
  • q quits.

The dotfile for a given output is ~/irandr-<outputname>.dat. If you run without an argument, it will list the valid xrandr outputs.

You can append a -setonly argument to the command line, which will read the settings for the given display's dotfile, update the display, and exit. (Useful, perhaps, in a ~/.bashrc file to automatically set a gamma/brightness.)

#!/bin/bash
# irandr.sh, by Dale Gass (dale@gass.ca)
# Wed Apr 10 16:43:22 EDT 2019

# Process arguments
if [ "$1" != "" ]
then
    output="$1"
else
    echo "Usage: irandr.sh <outputname> [-setonly]"
    echo "(Settings saved to ~/.xrandr-<outputname>.dat)"
    echo
    echo "Valid outputs:"
    xrandr | egrep -v '^( |Screen)'
    exit 1
fi
setonly=0
if [ "$2" = "-setonly" ]; then setonly=1; fi

# Initialize variables, read for dotfile if exists
cmdhelp="d/f/D/F=brightness j/k/J/K=gamma r=reset s=save l=load q=quit"
brightness=100
gamma=100
dotfile=~/.irandr-"$output".dat
if [ -s "$dotfile"  ]; then read brightness gamma <"$dotfile"; fi
if [ $setonly -eq 0 ]; then 
    echo $cmdhelp
    stty -echo raw intr $'\000' # Allow single character input
fi

# Main loop for setting adjustment
echo 'Bright Gamma'
while :
do
    b=$(bc <<< "scale=2; $brightness/100")  # Make 0.0-1.0
    g=$(bc <<< "scale=2; $gamma/100")
    xrandr --output "$output" --brightness "$b" --gamma "$g:$g:$g"
    printf "\r%4d %4d " $brightness $gamma
    if [ $setonly -eq 1 ]; then echo; exit 0; fi

    read -n1 ch     # Get input character from user
    case $ch in
    d) let brightness=brightness-5;; D) let brightness=brightness-1;;
    f) let brightness=brightness+5;; F) let brightness=brightness+1;;
    j) let gamma=gamma-5;;           J) let gamma=gamma-1;;
    k) let gamma=gamma+5;;           K) let gamma=gamma+1;;
    r) brightness=100; gamma=100;;
    s) echo "$brightness    $gamma" >"$dotfile" && echo -e "Saved\r";;
    l) read brightness gamma <"$dotfile"     && echo -e "Loaded\r";;
    q|$'\003') break;;
    *) echo -e "$cmdhelp\r";;
    esac
done

stty echo -raw intr $'\003' # Undo single character input

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.