安装NVIDIA驱动程序后亮度无法正常工作


26

我最近在Mac Book Pro 7,1上安装了Ubuntu 11.10。我安装了NVIDIA驱动程序(285)。亮度键正常工作(F1和F2),我看到显示亮度的框,但它什么也没做。我可以在“ NVIDIA X服务器设置”应用程序中更改亮度。在不卸载驱动程序的情况下如何获得亮度?提前致谢。


MacBook Pro 5,5在我身上也发生了同样的事情。
塞林2012年

1
只是后续操作,我尝试了所有记录在案的解决方案,但没有任何效果,包括使用最新的Nvida驱动程序。但是,当我清除Nvidia驱动程序并使用开源Nouveau驱动程序时,屏幕变暗立即开始起作用。
塞林2015年

@Cerin为什么不将其写为包括所有步骤的答案,以便新手用户可以遵循它?完成后,请给我评论,如果这是一个好的答案,我会投票赞成,这也可能会帮助其他人。
极客长老

1
@ElderGeek,不幸的是,Nouveau不支持挂起/恢复,这使它对笔记本电脑无用,这很可惜,因为它比Nvidia驱动程序更好。我升级到14.04和Nvidia 340驱动程序,现在可以进行屏幕调光。
塞林2015年

Answers:


43

我可以在Ubuntu 12.04上的Lenovo W530上使用亮度键。

如今,X会自动进行自我配置,因此创建xorg.conf文件可能会使您的系统不灵活。相反,您可以在/usr/share/X11/xorg.conf.d/中的文件中添加一个节,并且X将在自动生成的配置中包括该节。

因此,要使屏幕亮度键与Nvidia图形卡一起使用,请在xorg.conf.d目录中创建一个文件,例如:

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

将以下内容粘贴到文件中:

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

注销并重新登录,或重新启动,您的亮度键现在应该可以工作了!

(我在这里写了


谢谢,它适用于我在带有官方nvidia驱动程序(可从nvidia网站下载)的Lenovo W530的Ubuntu 14.04上使用。
塞德·扎林法姆

我有一台装有Linux Mint 17.3的W530机器,此解决方案直接适用(对我来说,注销并登录即可工作,无需重新启动)。
user22363 '16

运作良好,应该将其标记为正确答案
OKAN,2017年

1
在配备GeForce 9400M的Macbook 5.1上对我不起作用。g后启动进入黑屏。必须使用USB驱动器上的生命映像删除到文件。我正在重新安装Ubuntu Gnome 16.04。
钉头锤

3
如何找出BoardName?听起来可能很愚蠢,但这可能是我无法正常工作的原因。
davidbaumann

6

我的笔记本电脑有类似的问题,您需要添加一个选项 /etc/X11/xorg.conf

  1. 运行命令:

    sudo nano /etc/X11/xorg.conf
    
  2. 找到“设备”部分,并添加以下内容

    Option "RegistryDwords" "EnableBrightnessControl=1"    
    

这也适用于Ubuntu 12.04
shaneonabike 2013年

Xubuntu 12.04也可以正常工作
Stasik 2014年

在12.04中,这对我不起作用。
塞林2015年

在18.04中,这对我不起作用
Hany Alsamman

1
18.04没有此文件,但是创建一个新的.conf文件(如Chris Pearce的答案)也可以。
rogerdpack

4

您需要启用亮度控制。打开终端并键入sudo gedit /etc/x11/xorg.conf ,然后Option "RegistryDwords" "EnableBrightnessControl=1"device部分中添加,将其粘贴到新行中。然后重新启动计算机,一切都会正常。


不要在Ubuntu 18上执行此操作。路径x11应该为X11,并且应该在Section中,但是即使这样也不起作用。
Shital Shah

3

感谢您提供出色的脚本qgj。令人遗憾的是,该错误仍然存​​在,并且需要解决方法。由于James的选项对于我的特定显示类型在nvidia设置中不再有效,因此我遇到了与James出错相同的问题。幸运的是,背光亮度有一个更好的设置。我已经修改了bash脚本以改为使用此设置。

#!/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

您的里程可能因该脚本而异,因为某些显示器/适配器支持不同的选项。如果遇到问题,请阅读脚本中的帮助和注释。

希望它能对某人有所帮助!


1

有些计算机(例如我的联想W520)不Option "RegistryDwords" "EnableBrightnessControl=1"符合要求。如果您是那些不幸的人之一,则可以尝试nvidiabl驱动程序(在此处链接)。

nvidiabl驱动器提供改变屏幕亮度之有道。在某些笔记本电脑上,Option "RegistryDwords" "EnableBrightnessControl=1"骇客会导致背光控制器或您的GPU发出高音调噪音。

只需从此处下载并安装最新的Deb文件:https : //github.com/downloads/guillaumezin/nvidiabl/nvidiabl-dkms_0.72_all.deb

并运行:

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

以确保在计算机引导时加载模块。


1

我个人使用Vaio VPCCW21FX(Nvidia Graphic)和Ubuntu Studio 11.10 ..我尝试了许多解决方案,但没有任何方法可以解决LCD亮度问题!最后编写了这两个perl文件,以在Nvidia驱动程序配置文件中手动设置亮度/对比度和Gamma函数。

仅当您能够在Nvidia X服务器设置中更改亮度时,此功能才有用

步骤1:创建此文件并将其命名为“ Brightness-Up.pl”(您可以使用任何文本编辑工具,例如:gedit,nano,vi等。复制并粘贴)

    ### Code by forgottenrip@yahoo.com ###
    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`;

步骤2:然后制作另一个文件,将其命名为“ Brightness-Down.pl”,并填充以下代码:

    ### Code by forgottenrip@yahoo.com ###
    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`;

步骤3:您需要创建另一个包含Nvidia设置的文件。将其命名为“ Nvidia-Settings.cfg”,其名称的写法必须完全相同。填充:

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

而已!现在将这些文件放在唯一的文件夹中。.您必须将功能键绑定到这两个perl 文件。您可以使用Compiz>命令来完成。运行以下命令以安装compizconfig-settings-manager

sudo apt-get install compizconfig-settings-manager

或者甚至可以在shell(终端)中使用以下两个命令单独运行:

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

我将亮度文件放在其中的文件夹中。


1

NVIDIA亮度bash脚本

上面的perl脚本对我不起作用,所以我写了自己的脚本作为bash脚本(因为我不知道perl)。它有点长,但是它是自己创建设置文件的,可以与命令行选项一起使用,以同时调整亮度或灰度系数。我将它与--brightness-up和--brightness-down开关一起用于键盘上的亮度键。易于在XFCE4中进行分配,当然也可以在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

用法:

将文件保存在PATH中的某个位置,例如

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

别忘了

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

在使用它之前,您必须输入

nvidia-brightness.sh -i

这将创建设置文件,也可以随时用于重置亮度。

类型

nvidia-settings.sh --help

更多选项:

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

这正是我要找的东西,但出现错误:错误:解析分配'/ Gamma ='时出错(未指定属性值)。
詹姆斯

1

其他答案是尝试的好步骤,但是请注意,Ubuntu / Linux内核和Nvidia驱动程序的某些组合将无法使用。我使用12.04已有多年,即使我尝试了上述所有答案,我也无法获得任何Nvidia驱动程序来支持Macbook Pro 5,5上的屏幕变暗。

当我最终升级到14.04时,我尝试了Nouveau驱动程序,该驱动程序支持屏幕调光,并且速度通常更快,更可靠。不幸的是,它不支持挂起/恢复,因此在笔记本电脑上无法使用。我切换回Nvidia,但是几个驱动程序导致X / lightdm崩溃,甚至无法登录。我最终发现Nvidia 340驱动程序在Macbook Pro 5,5和Ubuntu 14.04上稳定并且还支持调光。


1

仅供参考,刚刚在Lenovo W520上完成了此工作,并添加了简单的行选项“ RegistryDwords”“ EnableBrightnessControl = 1”

到xorg.conf就足够了-不需要任何其他bossity,并且在当前NVidia版本(正常运行346.35)下都可以正常工作



0

从16.04升级后,我在Ubuntu 16.10中遇到了同样的问题。在xorg.conf文件(/ usr / share / doc / xserver-xorg-video-intel /)中,我将驱动程序从“ intel”更改为“ nvidia”。


2
感谢您的帮助!您介意对该过程进行一点描述吗?
EarthmeL17年

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.