34

I recently installed Ubuntu 11.10 on my Mac Book Pro 7,1. I installed the NVIDIA driver (285). The brightness keys are working (F1 and F2) and I get the box showing the brightness but it does nothing. I can change the brightness in the NVIDIA X Server Settings application. How can I get the brightness working without uninstalling the driver? Thanks in advance.

4
  • Same thing happened to me on a MacBook Pro 5,5.
    – Cerin
    Mar 11, 2012 at 18:20
  • 1
    Just a followup, I tried all the documented solutions, and nothing ever worked, including using the most recent Nvida driver. However, when I purged the Nvidia driver and used the open source Nouveau driver, screen dimming immediately started working.
    – Cerin
    Apr 15, 2015 at 13:21
  • @Cerin why not write that up as an answer including all the steps so that a novice user could follow it? Drop me a comment when you've done so and if it's a good answer, I'll upvote it, and it will likely help others as well.
    – Elder Geek
    May 1, 2015 at 1:23
  • 1
    @ElderGeek, Unfortunately, Nouveau doesn't support suspend/resume, making it useless for a laptop, which is a shame because it was otherwise better than the Nvidia driver. I upgraded to 14.04 and the Nvidia 340 driver, and now screen dimming works.
    – Cerin
    May 1, 2015 at 13:02

20 Answers 20

56

I was able to get my brightness keys working on my Lenovo W530 on Ubuntu 12.04.

These days X automatically configures itself, so creating an xorg.conf file might make your system inflexible. Instead you can add a section to a file in /usr/share/X11/xorg.conf.d/ and X will include that section in the configuration that it automatically generates.

So to get the screen brightness keys working with your Nvidia graphics card, create a file in the xorg.conf.d directory, e.g:

sudo gedit /usr/share/X11/xorg.conf.d/10-nvidia-brightness.conf

Paste the following into the file:

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro K1000M"
    Option         "RegistryDwords" "EnableBrightnessControl=1"
EndSection

Log out and log back in, or reboot, and your brightness keys should now work!

(I blogged this here)

11
  • Thank you, it works for me on Ubuntu 14.04 on Lenovo W530 with official nvidia driver (downloaded from nvidia site). May 9, 2015 at 7:10
  • I have a W530 machine with linux mint 17.3, this solution applies directly (for me just logging out and logging in works, no reboot needed).
    – user22363
    Dec 19, 2016 at 22:01
  • Worked perfectly, this should be marked as the correct answer
    – OKAN
    Mar 9, 2017 at 7:57
  • 1
    Didn't work for me on a macbook 5.1 with GeForce 9400M. Boots into a black screen after grub. Had to remove to file using a life-image from a usb-drive. Im on a fresh install of Ubuntu Gnome 16.04.
    – mace
    Jul 27, 2017 at 20:52
  • 3
    How to find out BoardName? Might sound stupid, but this might be the reason I don't get it to work. Sep 23, 2017 at 14:12
6

I had a similar issue with my laptop, there is an option you need to add to your /etc/X11/xorg.conf

  1. Run command:

    sudo nano /etc/X11/xorg.conf
    
  2. Find the line Section "Device" and add the following

    Option "RegistryDwords" "EnableBrightnessControl=1"    
    
5
  • This also works with Ubuntu 12.04 Sep 25, 2013 at 19:21
  • Xubuntu 12.04 works as well
    – Stasik
    Aug 17, 2014 at 15:01
  • This doesn't work for me in 12.04.
    – Cerin
    Apr 6, 2015 at 12:57
  • This doesn't work for me in 18.04 Aug 28, 2018 at 16:06
  • 1
    18.04 doesn't have this file but creating a new .conf file like Chris Pearce's answer works as well.
    – rogerdpack
    Jun 21, 2019 at 3:50
4

You need to enable Brightness Control. Open terminal and type sudo gedit /etc/x11/xorg.conf And then add Option "RegistryDwords" "EnableBrightnessControl=1" inside the device section, paste it in a new line. Then restart your computer and everything should be fine.

1
  • 2
    Don't do this on Ubuntu 18. The path x11 should X11 and this should be inside Section but even that doesn't work. Oct 18, 2019 at 0:48
3

Thank you for providing the great script qgj. It's sad that this bug still persists and the work-around is needed. I had the same issue as James getting an error due to the options no longer being valid with nvidia-settings for my specific display type. As luck would have it, there is a better setting available for backlight brightness. I have modified the bash script to use this setting instead.

#!/bin/bash

# This script was originally created by 'qgj' from askubuntu.  It has been modified
# to work using the BacklightBrighness setting available for some displays on the currrent nvidia driver
# It has also been modified to remove display specific configuration, instead applying the setting to all 
# active displays which support the BacklightBrightness setting.
# Tested only with nvidia-settings-319.12 and nvidia-drivers-331.20 on Linux Mint 17 Mate
#
# Requirements:
# - NVIDIA Drivers (e.g. nvidia-current in Ubuntu)
# - NVIDIA Settings (nvidia-settings in Ubuntu)
#
# This script can be used to change the brightness on systems with an NVIDIA graphics card
# that lack the support for changing the brightness (probably needing acpi backlight).
# It uses "nvidia-settings -a" to assign new gamma or brightness values to the display.
# 
# If this script fails, your display likely does not support the 'BacklightBrightness' option.
# In that event, execute 'nvidia-settings -n -q all' to see which options are available for the displays
#
# "nvidia-brightness.sh" may be run from the command line or can be assigned to the brightness keys on your Keyboard
# Type "nvidia-brightness.sh --help" for valid options.

if [ -z "${BASH}" ] ; then
    echo "please run this script with the BASH shell" 
    exit 1
fi

usage ()
{
cat << ENDMSG
Usage: 
   nvidia-brightness.sh [ options ]

Options:
   [ -bu ] or [ --brightness-up ]    increase brightness by 10
   [ -bu <no> ] or                   
   [ --brightness-up <no> ]          increase brightness by specified <no>

   [ -bd ] or [ --brightness-down ]  decrease brightness by 10
   [ -bd <no> ] or                   
   [ --brightness-down <no> ]        decrease brightness by specified <no>

   [ -i ]  or [ --initialize ]       Must be run once to create the settings file
                                     (~/.nvidia-brightness.cfg).
                                     Brightness settings from ~/.nvidia-settings-rc
                                     will be used if file exists, otherwise 
                                     brightness will be set to 100.
   [ -l ]  or [ --load-config ]      Load current settings from ~/.nvidia-brightness.cfg
                                     (e.g. as X11 autostart script)

Examples:
   nvidia-brightness -bd       this will decrease gamma by 10
   nvidia-brightness -bu 15    this will increase brightness by 15
ENDMSG
}

case $1 in 
    -h|--help)
        usage
        exit 0
esac

if [ "$1" != "-i" -a "$1" != "--initialize" ] ; then
    if [[ ! -f ~/.nvidia-brightness.cfg ]]; then 
        echo 'You must run this script with the --initialize option once to create the settings file.'
        echo 'Type "nvidia-brightness.sh --help" for more information.';
        exit 1
    fi
fi

#### INITIALIZE ####
initialize_cfg ()
{
    BRIGHTNESS_TEMP=100
    echo "BRIGHTNESS=$BRIGHTNESS_TEMP" > ~/.nvidia-brightness.cfg

    source ~/.nvidia-brightness.cfg
    echo "BRIGHTNESS: $BRIGHTNESS"

    # Valid BacklightBrightness values are between 0 and 100
    # Example:  nvidia-settings -n -a BacklightBrightness=80
    nvidia-settings -n -a BacklightBrightness=$BRIGHTNESS 1>/dev/null
    exit $?
}

#### LOAD CONFIGURATION ####
load_cfg ()
{
    source ~/.nvidia-brightness.cfg
    echo "BRIGHTNESS: $BRIGHTNESS"

    nvidia-settings -n -a BacklightBrightness=$BRIGHTNESS 1>/dev/null
}

#### BRIGHTNESS CHANGE ####
brightness_up ()
{
    source ~/.nvidia-brightness.cfg

    [[ -z $1 ]] && BRIGHTNESS_INC=10 || BRIGHTNESS_INC=$1
    BRIGHTNESSNEW=$(( $BRIGHTNESS + $BRIGHTNESS_INC ))
    [[ $BRIGHTNESSNEW -gt 100 ]] && BRIGHTNESSNEW=100

    sed -i  s/.*BRIGHTNESS=.*/BRIGHTNESS=$BRIGHTNESSNEW/g ~/.nvidia-brightness.cfg

    source ~/.nvidia-brightness.cfg
    echo "BRIGHTNESS: $BRIGHTNESS"

    nvidia-settings -n -a BacklightBrightness=$BRIGHTNESS 1>/dev/null
}

brightness_down ()
{
    source ~/.nvidia-brightness.cfg

    [[ -z $1 ]] && BRIGHTNESS_INC=10 || BRIGHTNESS_INC=$1
    BRIGHTNESSNEW=$(( $BRIGHTNESS - $BRIGHTNESS_INC ))
    [[ $BRIGHTNESSNEW -lt 0 ]] && BRIGHTNESSNEW=0

    sed -i  s/.*BRIGHTNESS=.*/BRIGHTNESS=$BRIGHTNESSNEW/g ~/.nvidia-brightness.cfg

    source ~/.nvidia-brightness.cfg
    echo "BRIGHTNESS: $BRIGHTNESS"

    nvidia-settings -n -a BacklightBrightness=$BRIGHTNESS 1>/dev/null
}

if [[ "$3" != "" ]]; then
    usage
    exit 1
fi

error_mixed_brightness ()
{
    echo "Error: [ --brightness-up ] and [ --brightness-down ] can't be used together."
}

if [[ "$2" != "" ]]; then
    [[ ! "$2" == ?(-)+([0-9]) ]] && usage && exit 1
fi

case $1 in
    -bu|--brightness-up) 
        [ "$2" == "-bd" ] && error_mixed_brightness && exit 1
        [ "$2" == "--brightness-down" ] && error_mixed_brightness && exit 1
        brightness_up $2
        ;;
    -bd|--brightness-down) 
        [ "$2" == "-bu" ] && error_mixed_brightness && exit 1
        [ "$2" == "--brightness-up" ] && error_mixed_brightness && exit 1
        brightness_down $2
        ;;
    -h|--help) 
        usage
        exit 0
        ;;
    -i|--initialize)
        if [ "$2" != "" ]; then usage; exit 1; fi   
        initialize_cfg
        exit $?
        ;;
    -l|--load-config)
        if [ "$2" != "" ]; then usage; exit 1; fi   
        load_cfg
        exit 0
        ;;
    *) 
        usage
        exit 1
esac

Your mileage may vary with this script as some displays/adapters support different options. If you encounter issues with it please read the help and comments in the script.

Hope it helps someone!

2

I have a MacBook Pro 2009 and I'm on Ubuntu 19.10 and this is how i fixed it.

Run this command:

sudo nano /usr/share/X11/xorg.conf.d/nvidia-drm-outputclass-ubuntu.conf 

Then I added the following line to the second to last line so right above the line that says "EndSection". I left the format like the rest of the other line in the file.

Option "RegistryDwords" "EnableBrightnessControl=1"

Then just reboot the device.

My file looked like this.

Section "OutputClass"
    Identifier "nvidia"
    MatchDriver "nvidia-drm"
    Driver "nvidia"
    ModulePath "/usr/lib/nvidia-340/xorg"
    Option "RegistryDwords" "EnableBrightnessControl=1"
EndSection
1
  • This also works in Macbook Pro mid-2010 under Linux Mint 19.3
    – ciaron
    Mar 23, 2020 at 10:23
1

There are some computers, such as my Lenovo W520, that don't with the Option "RegistryDwords" "EnableBrightnessControl=1" line. If you are one of those unlucky ones, you can try the nvidiabl driver (link here).

The nvidiabl driver provides a proper way to change the screen brightness. On some laptops the Option "RegistryDwords" "EnableBrightnessControl=1" hack will cause the backlight controller or your GPU to emit a high pitched noise.

Just download and install the latest Deb file from here: https://github.com/downloads/guillaumezin/nvidiabl/nvidiabl-dkms_0.72_all.deb

and run:

echo "nvidiabl" | sudo tee -a /etc/modules

to ensure that the module will be loaded when the computer boots.

1

Im personally using Vaio VPCCW21FX (Nvidia Graphic) and Ubuntu Studio 11.10 .. I tried many solutions and nothing could resolve my problem with LCD brightness! Finally wrote these two perl files to manually set brightness/Contrast and Gamma functions inside Nvidia driver config file.

This will be helpfull only if you are able to change brightness within Nvidia X Server Settings

Step 1: create this file and name it "Brightness-Up.pl" (you can use any text editing tool like : gedit,nano,vi,etc.. copy & paste)

    ### Code by [email protected] ###
    my $find1 = "0/RedBrightness=";my $find2 = "0/RedGamma=";
open FILE, "<Nvidia-Settings.cfg";
my @lines = <FILE>;
for (@lines) {
    if ($_ =~ /$find1/) { chomp $_;$value= substr($_,16,5); }
    if ($_ =~ /$find2/) { chomp $_;$value2= substr($_,11,5);}     
}
my @Lines;
if ( $value > 0.0) { $value = $value - 0.30 };  
if ( $value2 > 1.1) { $value2 = $value2 - 0.08 };  
$last_value = $value + 0.30;
$Lines[0] ="0/RedBrightness=".$last_value;
$Lines[1] ="0/GreenBrightness=".$last_value;;
$Lines[2] ="0/BlueBrightness=".$last_value;;
$last_value = $value + 0.30;
$Lines[3] ="0/RedContrast=".$last_value;;
$Lines[4] ="0/GreenContrast=".$last_value;;
$Lines[5] ="0/BlueContrast=".$last_value;;
$last_value = $value2 + 0.08;
$Lines[6] ="0/RedGamma=".$last_value;;
$Lines[7] ="0/GreenGamma=".$last_value;;
$Lines[8] ="0/BlueGamma=".$last_value;;

$filename = "Nvidia-Settings.cfg";
open fh2,'>',$filename or die ("can't open '$filename': $! \n");
foreach ( @Lines )
{ chomp;print "$_\n";print fh2 "$_\n"; };
close fh2; 
`nvidia-settings -l --config=Nvidia-Settings.cfg`;

Step 2: then make another file, name it "Brightness-Down.pl" and fill with this code:

    ### Code by [email protected] ###
    my $find1 = "0/RedBrightness=";my $find2 = "0/RedGamma=";
open FILE, "<Nvidia-Settings.cfg";
my @lines = <FILE>;
for (@lines) {
    if ($_ =~ /$find1/) {chomp $_;$value= substr($_,16,5);}
    if ($_ =~ /$find2/) {chomp $_;$value2= substr($_,11,5);}     
}
my @Lines;
if ( $value < -0.80) { $value = $value + 0.30 };  
if ( $value2 < 0.8) { $value2 = $value2 + 0.08 };  
$last_value = $value - 0.30;
$Lines[0] ="0/RedBrightness=".$last_value;
$Lines[1] ="0/GreenBrightness=".$last_value;;
$Lines[2] ="0/BlueBrightness=".$last_value;;
$last_value = $value - 0.30;
$Lines[3] ="0/RedContrast=".$last_value;;
$Lines[4] ="0/GreenContrast=".$last_value;;
$Lines[5] ="0/BlueContrast=".$last_value;;
$last_value = $value2 - 0.08;
$Lines[6] ="0/RedGamma=".$last_value;;
$Lines[7] ="0/GreenGamma=".$last_value;;
$Lines[8] ="0/BlueGamma=".$last_value;;

$filename = "Nvidia-Settings.cfg";
open fh2,'>',$filename or die ("can't open '$filename': $! \n");
foreach ( @Lines )
{ chomp;print "$_\n";print fh2 "$_\n"; };
close fh2; 
`nvidia-settings -l --config=Nvidia-Settings.cfg`;

Step 3: You need to create another file which contains Nvidia Settings.. name it "Nvidia-Settings.cfg" its important that you write name exactly same. fill with:

0/RedBrightness=0.1
0/GreenBrightness=0.1
0/BlueBrightness=0.1
0/RedContrast=0.1
0/GreenContrast=0.1
0/BlueContrast=0.1
0/RedGamma=1.14
0/GreenGamma=1.14
0/BlueGamma=1.14

Thats it! now place these files in unique folder.. you have to bind your Function Keys to these two perl file.you can use Compiz>commands to do that. Run below command to install the compizconfig-settings-manager

sudo apt-get install compizconfig-settings-manager

or even you can run seperately with these two commands in shell (terminal):

user$ perl Brightness/Brightness-Up.pl
user$ perl Brightness/Brightness-Down.pl

where Brightness is folder I put those files in it.

1

NVIDIA brightness bash script

The above perl script didnt work for me so I wrote my own script as a bash script (since I don't know perl). It got a bit long but it creates the settings file by itself and can be used with command line options to adjust brightness or gamma or both at the same time. I use it with the --brightness-up and --brightness-down switches for the brightness keys on my Keyboard. Easy to assign in XFCE4 and surely also in KDE / GNOME.

nvidia-brightness.sh:

#!/bin/sh

# Tested only with nvidia-settings-319.12 and nvidia-drivers-319.17 on Funtoo Linux running XFCE 4.10
#
# Requirements:
# - NVIDIA Drivers (e.g. nvidia-current in Ubuntu)
# - NVIDIA Settings (nvidia-settings in Ubuntu)
# - xrandr (used by default to determine the correct display name)
#
# This script can be used to change the brightness on systems with an NVIDIA graphics card
# that lack the support for changing the brightness (probably needing acpi backlight).
# It uses "nvidia-settings -a" to assign new gamma or brightness values to the display.
#
# "nvidia-brightness.sh" may be run from the command line or can be assigned to the brightness keys on your Keyboard
# e.g. in XFCE4.
#
# Type "nvidia-brightness.sh --help" for valid options.

usage ()
{
cat << ENDMSG
Usage: 
   nvidia-brightness.sh [ options ]
Options:
   [ -gu ] or [ --gamma-up ]         increase gamma by 0.1
   [ -gd ] or [ --gamma-down ]       decrease gamma by 0.1
   [ -bu ] or [ --brightness-up ]    increase brightness by 0.1
   [ -bd ] or [ --brightness-down ]  decrease brightness by 0.1
   [ -i ]  or [ --initialize ]       Must be run once to create the settings file
                                     (~/.nvidia-brightness.cfg).
                                     Brightness settings from ~/.nvidia-settings-rc
                                     will be used if file exists, otherwise 
                                     gamma will be set to 1.0 and brightness to 0.0
                                     (NVIDIA Standard).
   [ -l ]  or [ --load-config ]      Load current settings from ~/.nvidia-brightness.cfg
                                     (e.g. as X11 autostart script)

Examples:
   nvidia-brightness -gd       this will decrease gamma by 0.1
   nvidia-brightness -bu -gd   this will increase brightness by 0.1 and decrease gamma by 0.1
ENDMSG
}

case $1 in 
    -h|--help)
        usage
        exit 0
esac

if [ "$1" != "-i" -a "$1" != "--initialize" ]; then
    if [ ! -f ~/.nvidia-brightness.cfg ]; then 
        echo 'You must run this script with the --initialize option once to create the settings file.'
        echo 'Type "nvidia-brightness.sh --help" for more information.';
        exit 1
    fi
fi

#### INITIALIZE ####
initialize_cfg ()
{
CONNECTED="[`xrandr | grep " connected" | awk '{ print $1 }'`]"
#CONNECTED="`cat ~/.nvidia-settings-rc  | grep RedBrightness | grep -o "\[.*]"`"
#CONNECTED="[DVI-I-1]"
#CONNECTED="[dpy:2]"
#CONNECTED="0"

if [ -f ~/.nvidia-settings-rc ]; then 
    if [ "`grep RedGamma ~/.nvidia-settings-rc`" != "" ]; then
        if [ "`grep RedBrightness ~/.nvidia-settings-rc`" != "" ]; then
            GAMMA_TEMP=`grep RedGamma= ~/.nvidia-settings-rc | sed s/^.*=//`
            BRIGHTNESS_TEMP=`grep RedBrightness= ~/.nvidia-settings-rc | sed s/^.*=//`
            NVIDIA_SETTINGS_OK=1
        fi
    fi
fi


[ "$NVIDIA_SETTINGS_OK" != "1" ] && \
GAMMA_TEMP=1.000000 \
BRIGHTNESS_TEMP=0.000000

echo "\
CONNECTED_DISPLAY=$CONNECTED
GAMMA=$GAMMA_TEMP
BRIGHTNESS=$BRIGHTNESS_TEMP" > ~/.nvidia-brightness.cfg

source ~/.nvidia-brightness.cfg

GAMMACOMMA=`echo $GAMMA | sed s/"\."/"\,"/`
BRIGHTNESSCOMMA=`echo $BRIGHTNESS | sed s/"\."/"\,"/`

nvidia-settings -n -a $CONNECTED_DISPLAY/Gamma=$GAMMACOMMA -a $CONNECTED_DISPLAY/Brightness=$BRIGHTNESSCOMMA 1>/dev/null
}

#### LOAD CONFIGURATION ####
load_cfg ()
{
source ~/.nvidia-brightness.cfg

GAMMACOMMA=`echo $GAMMA | sed s/"\."/"\,"/`
BRIGHTNESSCOMMA=`echo $BRIGHTNESS | sed s/"\."/"\,"/`

nvidia-settings -n -a $CONNECTED_DISPLAY/Gamma=$GAMMACOMMA -a $CONNECTED_DISPLAY/Brightness=$BRIGHTNESSCOMMA 1>/dev/null
}

#### GAMMA CHANGE ####
gamma_up ()
{
source ~/.nvidia-brightness.cfg

GAMMANEW=`echo $GAMMA | awk '{printf "%f", $GAMMA + 0.100000}'`

GAMMACOMMA=`echo $GAMMANEW | sed s/"\."/"\,"/`

nvidia-settings -n -a $CONNECTED_DISPLAY/Gamma=$GAMMACOMMA  1>/dev/null 

sed -i  s/.*GAMMA=.*/GAMMA=$GAMMANEW/g ~/.nvidia-brightness.cfg
}

gamma_down ()
{
source ~/.nvidia-brightness.cfg

GAMMANEW=`echo $GAMMA | awk '{printf "%f", $GAMMA - 0.100000}'`

GAMMACOMMA=`echo $GAMMANEW | sed s/"\."/"\,"/`

nvidia-settings -n -a $CONNECTED_DISPLAY/Gamma=$GAMMACOMMA  1>/dev/null

sed -i  s/.*GAMMA=.*/GAMMA=$GAMMANEW/g ~/.nvidia-brightness.cfg
}

#### BRIGHTNESS CHANGE ####
brightness_up ()
{
source ~/.nvidia-brightness.cfg

BRIGHTNESSNEW=`echo $BRIGHTNESS | awk '{printf "%f", $BRIGHTNESS + 0.100000}'`

BRIGHTNESSCOMMA=`echo $BRIGHTNESSNEW | sed s/"\."/"\,"/`

nvidia-settings -n -a $CONNECTED_DISPLAY/Brightness=$BRIGHTNESSCOMMA 1>/dev/null

sed -i  s/.*BRIGHTNESS=.*/BRIGHTNESS=$BRIGHTNESSNEW/g ~/.nvidia-brightness.cfg
}

brightness_down ()
{
source ~/.nvidia-brightness.cfg

BRIGHTNESSNEW=`echo $BRIGHTNESS | awk '{printf "%f", $BRIGHTNESS - 0.100000}'`

BRIGHTNESSCOMMA=`echo $BRIGHTNESSNEW | sed s/"\."/"\,"/`

nvidia-settings -n -a $CONNECTED_DISPLAY/Brightness=$BRIGHTNESSCOMMA 1>/dev/null

sed -i  s/.*BRIGHTNESS=.*/BRIGHTNESS=$BRIGHTNESSNEW/g ~/.nvidia-brightness.cfg
}

if [ "$3" != "" ]; then
    usage
    exit 1
fi

error_mixed_gamma ()
{
    echo "Error: [ --gamma-up ] and [ --gamma-down ] can't be used together."
}

error_mixed_brightness ()
{
    echo "Error: [ --brightness-up ] and [ --brightness-down ] can't be used together."
}


if [ "$2" != "" ]; then
    [ "$2" != "-bu" -a "$2" != "--brightness-up" -a "$2" != "-bd" -a "$2" != "--brightness-down" \
    -a "$2" != "-gu" -a "$2" != "--gamma-up" -a "$2" != "-gd" -a "$2" != "--gamma-down" ] && usage && exit 1
fi

case $1 in
    -gu|--gamma-up) 
        [ "$2" == "-gd" ] && error_mixed_gamma && exit 1
        [ "$2" == "--gamma-down" ] && error_mixed_gamma && exit 1
        gamma_up
        ;;
    -gd|--gamma-down) 
        [ "$2" == "-gu" ] && error_mixed_gamma && exit 1
        [ "$2" == "--gamma-up" ] && error_mixed_gamma && exit 1
        gamma_down
        ;;
    -bu|--brightness-up) 
        [ "$2" == "-bd" ] && error_mixed_brightness && exit 1
        [ "$2" == "--brightness-down" ] && error_mixed_brightness && exit 1
        brightness_up
        ;;
    -bd|--brightness-down) 
        [ "$2" == "-bu" ] && error_mixed_brightness && exit 1
        [ "$2" == "--brightness-up" ] && error_mixed_brightness && exit 1
        brightness_down
        ;;
    -h|--help) 
        usage
        exit 0
        ;;
    -i|--initialize)
        if [ "$2" != "" ]; then usage; exit 1; fi   
        initialize_cfg
        exit 0
        ;;
    -l|--load-config)
        if [ "$2" != "" ]; then usage; exit 1; fi   
        load_cfg
        exit 0
        ;;
    *) 
        usage
        exit 1
esac

case $2 in
    -gu|--gamma-up) 
        gamma_up
        ;;
    -gd|--gamma-down) 
        gamma_down
        ;;
    -bu|--brightness-up) 
        brightness_up
        ;;
    -bd|--brightness-down) 
        brightness_down
        ;;
    -h|--help) 
        usage
        exit 0
        ;;
    "")
        ;;
    *) 
        usage
        exit 1
esac

Usage:

Save the file somewhere in your PATH e.g.

/usr/local/bin/nvidia-brightness.sh

Don't forget to

chmod +x /usr/local/bin/nvidia-brightness.sh

Before you can use it you have to type

nvidia-brightness.sh -i

This will create the settings file and can also be used to reset the brightness at any time.

Type

nvidia-settings.sh --help

for more options:

Usage: 
   nvidia-brightness.sh [ options ]
Options:
   [ -gu ] or [ --gamma-up ]         increase gamma by 0.1
   [ -gd ] or [ --gamma-down ]       decrease gamma by 0.1
   [ -bu ] or [ --brightness-up ]    increase brightness by 0.1
   [ -bd ] or [ --brightness-down ]  decrease brightness by 0.1
   [ -i ]  or [ --initialize ]       Must be run once to create the settings file
                                     (~/.nvidia-brightness.cfg).
                                     Brightness settings from ~/.nvidia-settings-rc
                                     will be used if file exists, otherwise 
                                     gamma will be set to 1.0 and brightness to 0.0
                                     (NVIDIA Standard).
   [ -l ]  or [ --load-config ]      Load current settings from ~/.nvidia-brightness.cfg
                                     (e.g. as X11 autostart script)

Examples:
   nvidia-brightness -gd       this will decrease gamma by 0.1
   nvidia-brightness -bu -gd   this will increase brightness by 0.1 and decrease gamma by 0.1
1
  • This looks exactly what I'm looking for but I get an error: ERROR: Error parsing assignment '/Gamma=' (No attribute value specified).
    – James
    Oct 9, 2013 at 20:25
1

The other answers are good steps to try, but note that some combinations of Ubuntu/Linux Kernel and the Nvidia driver just won't work. I used 12.04 for years, and even though I tried all the above answers, I couldn't get any of the Nvidia drivers to support screen dimming on my Macbook Pro 5,5.

When I finally upgraded to 14.04, I tried the Nouveau driver, which did support screen dimming, and was generally faster and more reliable and Nvidia. Unfortunately, it doesn't support suspend/resume, making it useless on a laptop. I switched back to Nvidia, but several drivers caused X/lightdm to crash, preventing me from even logging in. I finally found that the Nvidia 340 driver was stable with my Macbook Pro 5,5 and Ubuntu 14.04 and also supported dimming.

1

FYI, just worked through this on a Lenovo W520, and the addition of the simple line Option "RegistryDwords" "EnableBrightnessControl=1"

to xorg.conf was enough - no need for any of the other bogosity, and all works fine with a current NVidia release (specifically, running 346.35)

1

Here is what worked for me on Ubuntu 18.04 (Credits to all the previous answers)

  1. First open NVIDIA X Server Setting
  2. Goto X Server Display Configuration Section and press the Save to X Configuration File. This will create a new file /etc/X11/xorg.conf.
  3. Then open this new file using sudo nano /etc/X11/xorg.conf
  4. Find the Device Section it will look something like this
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1650 Ti"
EndSection
  1. Add the new Option -> Option "RegistryDwords" "EnableBrightnessControl=1" . In the end it will look something like this
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1650 Ti"
    Option "RegistryDwords" "EnableBrightnessControl=1"
EndSection

Hope it helps :D

1

After much research and hit-and-trial of the solutions provided online, only this solution worked for me.

nvidia.NVreg_RegistryDwords=EnableBrightnessControl=1

Edit /etc/default/grub and change to the following lines:

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nvidia.NVreg_RegistryDwords=EnableBrightnessControl=1"
GRUB_CMDLINE_LINUX=""

The answer was found from Nvidia Forum

1
  • Upvoted. Based on this person's testing, and a little of my own, apparently NVIDIAs drivers have had a regression in this regard, so your fix works on driver version 470, but not 515, 520, or 525 (I tested 525.60.11 myself here, and it does not work on that version). :( Dec 21, 2022 at 11:16
1

How to find an NVIDIA driver which works with your brightness function buttons

Solved! Many of NVIDIA's video drivers on Linux have regressions, breaking screen brightness control in later driver versions, so you should install the latest NVIDIA driver first, and then if your screen brightness control doesn't automatically work after rebooting (without any of the other fixes on this page), then progressively install older and older NVIDIA driver versions straight from the manufacturer until one naturally works with your screen brightness control function buttons.

Tested on a Lenovo ThinkPad P15 Gen 2 laptop with these specs: NVIDIA RTX A2000 4GB GDDR6 graphics card and Intel Core i9-11950H processor (8 cores/16 threads), in Ubuntu 22.04.

First, what does not work

I tried nearly every answer to this entire question, including modifying the /etc/default/grub file, the /usr/share/X11/xorg.conf.d/10-nvidia-brightness.conf file, and the /etc/X11/xorg.conf file, as well as writing directly to the /sys/class/backlight/nvidia_0/brightness file via echo 100 > /sys/class/backlight/nvidia_0/brightness, for instance. I tried these settings while booting with both the X11 video server/window manager, as well as Wayland. It made no difference. None of these "fixes" worked.

I also tried other fixes from other sites and forums. For my laptop and the NVIDIA 525.60.11 Linux graphics driver, none of those other solutions worked!

Again, I got the same results with both Wayland and X.

This really helpful post from @adrianer84 is what gave me the idea to try older and older driver versions until one worked. He said:

I can confirm, that

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nvidia.NVreg_RegistryDwords=EnableBrightnessControl=1"

on Ubuntu 22.04 and GeForce RTX 3600 mobile with the 470.XX.XX driver works on a Legion 7 (2021) (16ACHg6) for controlling the backlight - while it does not with 515.XX or 520.56.06 (with 520.56.06 there is even one more regression: the backlight is completely off after sleep - so the display is basically off. As you cannot control it, you have to force-reboot…).

What does work but which I do not recommend you do

Your BIOS/UEFI probably supports (it should) setting your graphics mode between "Hybrid Graphics" and "Discrete Graphics". NVIDIA says you must use "Discrete Graphics" mode to be compatible with their driver. However, if you set your mode to "Hybrid Graphics", it does make your brightness buttons work again because then your internal graphics card built into the CPU will handle that, but then again your NVIDIA graphics driver will also be glitchy and you may notice problems, and NVIDIA says to use "Discrete" mode.

So, boot into your BIOS/UEFI and change your settings to "Discrete Graphics" mode:

enter image description here

The meaning my UEFI tells me is (emphasis added):

  • Discrete Graphics mode will achieve higher graphics performance.
  • Hybrid Graphics mode runs as Integrated Graphics mode to achieve longer battery life, and Discrete Graphics is enabled on demand.

That tells me that the internal integrated graphics card built into the CPU chip is more-efficient, and the NVIDIA card is the external "Discrete Graphics" card.

enter image description here

NVIDIA says to use "Discrete Graphics" only, however, under the "Additional Information" tab of their download links, such as here for 515.86.01, for instance: https://www.nvidia.com/download/driverResults.aspx/194662/en-us/ (emphasis added):

Some designs incorporating supported GPUs may not be compatible with the NVIDIA Linux driver: in particular, notebook and all-in-one desktop designs with switchable (hybrid) or Optimus graphics will not work if means to disable the integrated graphics in hardware are not available.

Installing a slightly older driver version (515.86.01 instead of 525.60.11, in my case) did work!

What did work, however, was installing the NVIDIA 515.86.01 driver instead, which was the previous version in the "500" version series in the list, as shown here with these search parameters: https://www.nvidia.com/Download/Find.aspx?lang=en-us:

enter image description here

So, the solution is to follow Option 2 in my detailed NVIDIA graphics driver installation instructions here: How to install the proper NVIDIA graphics driver to hopefully prevent freezes.

Start by installing the latest NVIDIA driver for your graphics card. Then, reboot, log in, and try your brightness function keys. If they work, you're done! If they don't, go to the NVIDIA "Advanced Driver Search" page and install the next-oldest driver down the list in your driver version series, possibly skipping "Beta" and "NFB" (whatever that means) versions, until one works.

So, to make the point and demonstrate the order in which I'd try the drivers, if I was doing this based on the driver list in the image just above, I'd try the driver versions in this order (probably sticking to the later 500 series versions unless they all failed to work too):

  1. 525.60.11 - brightness buttons don't work for me!
  2. [optionally skip the 470.161.03 one since it's an older version series]
  3. 515.86.01 - brightness buttons do work for me!
  4. 510.108.03
  5. [optionally skip 525.53 since it's a Beta release]
  6. [optionally skip 520.56.06 since it's an NFB release--whatever that means]
  7. 515.76
  8. [optionally skip 470.141.03 since it's an older version series]
  9. 515.65.01
  10. etc.

Please report in the comments your laptop, graphics card, and which driver versions do or don't work for you to have brightness control via your function buttons.

I do not recommend just using an older version to start, as it's super easy and fast (< 5 minutes) to install a new driver version once you get the hang of it, and we want to get the latest driver version possible that doesn't have regressions, to get the latest features and bug-fixes.

1
  • 1
    Lenovo X1 extreme, gtx 1050 Ti Mobile. nvidia-driver-525 version 525.85.05 have issue. I've just rollback to nvidia-driver-515 and it works just fine again.
    – broomrider
    Mar 6, 2023 at 17:04
0

Im using NVIDIA Graphic Card and having problem like you.
But i tried this thing and it's work :

1. Install NVIDIA Driver with command :
sudo apt-add-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install nvidia-current
2. Then, reboot
3. Done.

Source : http://noob-tech.blogspot.co.id/2015/04/Install-VGA-Driver-On-Ubuntu.html

0

I had the same problem in Ubuntu 16.10, after upgrading from 16.04. In the xorg.conf file (/usr/share/doc/xserver-xorg-video-intel/), I changed the driver from "intel" to "nvidia".

1
  • 2
    Thanks for trying to help! Would you mind describing the process a bit?
    – earthmeLon
    Jan 31, 2017 at 20:33
0

Going back to linux kernel 4.4 fixed the problem on my Macbook Pro Late 2013 15".

0

I had multiple issues with my laptop Lenovo IdeaPad S340 15IIL like
1.unable to control brighness tried every possible solution didnt worked 2.wifi not working with intel AC9560 chip,
3.Nvidia GeForce MX250 not integrating
4.hdaudioc0d2 unable to bind the codec error on boot

Solution
Use Disk Startup creator Better Try Reinstalling the ubuntu by creating fresh bootable usb using another ubuntu system's utility Disk Startup creator application which is already provided in every ubuntu now days.


0

I have an old Macbook 6,1 that I installed Ubuntu 18.04 on, and enabled the nvidia driver. To get the brightness controls working again, as various suggestions in this thread mention, I added the following line:

Option         "RegistryDwords" "EnableBrightnessControl=1"

Into the OutputClass section of the following file:

/usr/share/X11/xorg.conf.d/nvida-drm-outputclass-ubuntu.conf

After that, restart x:

sudo systemctl restart display-manager

Once I logged back in, the brightness controls worked like a charm.

0

This is an old post but it kept coming up any time I searched about this same problem. I solved the issue by installing xbacklight but I wanted to make the solution more integrated by attaching it to my startup and hotkeys so I could easily adjust the brightness any time.

I used the following script, call it from my startup app list and also call "brightness up" and "brightness down" from hotkeys configured in the keyboard shortcut tool. (or directly on the command line). Just put the script in a reasonable place and make it executable. Then you can start using it. It will try to install xbacklight for you if you don't already have it installed.

#!/bin/bash
#
# Run this script at startup to initialize the desired brightness
#
# Run it using hotkeys to easily increase/decrease the brightness.
#
# Usage: brightness up
#        brightness down
#        brightness
#

brightnessFile=`readlink -f ~/.config/brightness`
numeric='^[0-9]+$'
save=0
brightness=`cat $brightnessFile 2>/dev/null`

if [[ ! $brightness =~ $numeric ]]; then
    brightness=85
fi

if [ "$1" == "up" ]; then
    brightness=$(($brightness + 5))
    save=1
fi

if [ "$1" == "down" ]; then
    brightness=$(($brightness - 5))
    save=1
fi

if [ $brightness -gt 100 ]; then
    brightness=100
    save=1
fi

if [ $brightness -lt 0 ]; then
    brightness=0
    save=1
fi

if [ "$save" == "1" ]; then
    echo $brightness > $brightnessFile
fi

xbacklight -set $brightness >/dev/null 2>&1
if [ "$?" != "0" ]; then
    # try to install xbacklight
    export SUDO_ASKPASS=`which ssh-askpass`
    sudo -A apt-get -y install xbacklight
    xbacklight -set $brightness >/dev/null 2>&1
fi
if [ "$?" == "0" ]; then
    echo "Brightness set to $brightness%"
else
    echo "Can't adjust the brightness"
    exit 1
fi
0

None of these methods worked for me. I am using a Lenovo laptop with an Nvidia GeForce GTX 1650.

I figured out a way to make it work by appending

nvidia.NVreg_RegistryDwords=EnableBrightnessControl=1

to grub.

Steps:

  • Do sudo gedit /etc/default/grub :

  • Edit this line:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet nvidia.NVreg_RegistryDwords=EnableBrightnessControl=1"
    
  • Save and exit gedit

  • Update GRUB with:

    sudo update-grub
    
  • Restart.

I found this solution on ArchWiki. I use Debian 11.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .