当前位置: 首页>>技术教程>>正文


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

, ,

问题描述

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

最佳思路

我能够在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

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

(我从here转发了此帖)

次佳思路

我的笔记本电脑出现类似问题,您需要将其添加到/etc/X11/xorg.conf

  1. 运行命令:

    sudo nano /etc/X11/xorg.conf
    
  2. 找到第”Device”节,并添加以下内容

    Option "RegistryDwords" "EnableBrightnessControl=1"    
    

第三种思路

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

第四种思路

感谢您提供出色的脚本qgj。令人遗憾的是,该错误仍然存​​在,需要使用work-around。由于选项对于我的特定显示类型在nvidia-settings中不再有效,因此我遇到了与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

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

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

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/9614.html,未经允许,请勿转载。