教你在Ubuntu系統下儲存螢幕亮度設定

weixin_34344677發表於2013-07-01
 本文保留螢幕亮度方法適合使用筆記本的朋友,大家都知道,過亮的螢幕不但刺眼而且縮短LCD螢幕壽命,不幸的是,Ubuntu預設關機後並不儲存當前螢幕亮度配置資料,每次開機都要重新設定亮度,很不方便。本文介紹的方法可以徹底解決這個問題!
    1.修改/etc/default/acpi-support
    ENABLE_LAPTOP_MODE=true
    2.修改 /etc/laptop-mode/laptop-mode.conf
    交流電模式下使用 laptop mode
    #
    # Enable laptop mode when on AC power.
    #
    ENABLE_LAPTOP_MODE_ON_AC=1
    #電池那也可設為1
    使用 laptop mode 進行LCD亮度控制
    #
    # Should laptop mode tools control LCD brightness?
    #
    CONTROL_BRIGHTNESS=1
    #
    # Commands to execute to set the brightness on your LCD
    #
    BATT_BRIGHTNESS_COMMAND=”echo 0″
    LM_AC_BRIGHTNESS_COMMAND=”echo 9″
    NOLM_AC_BRIGHTNESS_COMMAND=”echo 9″
    BRIGHTNESS_OUTPUT=”/sys/class/backlight/acpi_video1/brightness”
    如果你不明白上面的設定的意思,可以參考下面的說明:
    ***********************************
    # * If your system has the file “/proc/acpi/video/VID/LCD/brightness” (VID may
    # be VID1 or similar), use this file as BRIGHTNESS_OUTPUT, and use
    # the command “echo “. The possible values can be listed using the
    # command:
    #
    # cat /proc/acpi/video/VID/LCD/brightness
    # * If you have a file /sys/class/backlight/…/brightness, then you can use
    # that file as BRIGHTNESS_OUTPUT, and the command “echo “.
    #
    # As far as I understand it the values are between 0 and
    # the value contained in the file /sys/class/backlight/…/max_brightness.
    **********************************
 
 
 
*****************************************
Ubuntu 無法調節並儲存螢幕亮度解決辦法
[日期:2012-09-13]
測試環境:
Acer Aspire 5750G
NVIDIA GeForce GT630M
Ubuntu 12.04 x86_64
其他情況解決方法類似。
調節螢幕亮度
Fn不能調節螢幕的亮度。因為fn調節的是/sys/class/backlight/acpi_video0/brightness檔案,而I卡的檔案是/sys/class/backlight/intel_backlight/brightness。
一、測試程式碼
啟動系統,出現grub選單時,按“e”編輯,在有linux核心路徑那一行,新增“acpi_backlight=vendor”,如:
linux    /boot/vmlinuz-3.2.0-30-generic root=UUID=75c414be-2e17-407a-b699-94f6a398dff7 ro acpi_backlight=vendor  quiet splash
如果能正常啟動,且用fn能調節螢幕亮度,說明成功,接著下一步。
二、修改grub
sudo vi /etc/default/grub
找到:
GRUB_CMDLINE_LINUX=""
改為:
GRUB_CMDLINE_LINUX="acpi_backlight=vendor“
我的grub檔案如下:
# If you change this file, run 'update-grub' afterwards to update
#
# /boot/grub/grub.cfg.
#
# For full documentation of the options in this file, see:
#
#   info -f grub -n 'Simple configuration'
 
G
GRUB_DEFAULT=0
#
#GRUB_HIDDEN_TIMEOUT=0
G
GRUB_HIDDEN_TIMEOUT_QUIET=true
G
GRUB_TIMEOUT=3
G
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
G
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
G
GRUB_CMDLINE_LINUX="acpi_backlight=vendor"
 
#
# Uncomment to enable BadRAM filtering, modify to suit your needs
#
# This works with Linux (no patch required) and with any kernel that obtains
#
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
 
#
# Uncomment to disable graphical terminal (grub-pc only)
#
#GRUB_TERMINAL=console
 
 
 
#
# The resolution used on graphical terminal
#
# note that you can use only modes which your graphic card supports via VBE
#
# you can see them in real GRUB with the command `vbeinfo'
 
#GRUB_GFXMODE=640x480
 
#
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#
#GRUB_DISABLE_LINUX_UUID=true
 
#
# Uncomment to disable generation of recovery mode menu entries
#
#GRUB_DISABLE_RECOVERY="true"
 
#
# Uncomment to get a beep at grub start
#
#GRUB_INIT_TUNE="480 440 1"
更新grub.cfg
?  ~  sudo update-grub
 
檢視grub.cfg 發現其中每個啟動項都加入了“acpi_backlight=vendor”
?  ~  vi /boot/grub/grub.cfg
設定螢幕初始亮度
重啟後發現,螢幕亮度又恢復為最大亮度。
檢視影響螢幕亮度的檔案
?  ~  vi /sys/class/backlight/intel_backlight/brightness
調節幾次螢幕亮度發現其中數值會改變,我的筆記本數值範圍為0~976。
手動修改該數值,會發現螢幕亮度隨之改變(需要root使用者執行):
?  ~  su  
Password: 
root@ www.linuxidc.com :/home/congbo# echo 500 > /sys/class/backlight/intel_backlight/brightness
因此,將該語句新增到 /etc/rc.local 就能開機自動設定螢幕初始亮度了。
修改/etc/rc.local如下(需要root使用者執行):
#!/bin/sh -e
#
#
#
# rc.local
#
#
#
# This script is executed at the end of each multiuser runlevel.
#
# Make sure that the script will “exit 0″ on success or any other
#
# value on error.
#
#
#
# In order to enable or disable this script just change the execution
#
# bits.
#
#
#
# By default this script does nothing.
 
 
 
echo 500 > /sys/class/backlight/intel_backlight/brightness
e
exit 0
調節gamma值
?  ~  xgamma -gamma .7
-> Red  1.000, Green  1.000, Blue  1.000
<- Red  0.700, Green  0.700, Blue  0.700

相關文章