日期:2014-05-16  浏览次数:20737 次

调节linux显示亮度和对比度的shell script
相信很多童鞋发现自己的笔记本在安装unbutu/fedora这些linux distrobution后,通过Fn键无法修改亮度了吧。查了一些资料,发现是系统无法调用控制亮度,写了小脚本,方便大家使用:
#!/bin/bash

value=$2 #init value

usage(){
    echo "Usage: $0 [-g][-b] <value>"
    echo "-g --gamma        set the gamma value from 0.1-10.0"
    echo "-b --brightness   set the brightness value from 0(dark)-99"
    echo "                  brightness suggest value is 25,50,75,90"
}

vga_brightness(){
    vga_interface=`lspci | grep VGA | awk '{print $1}'`
    sudo setpci -s $vga_interface F4.B=$value
}

vga_gamma(){
    xgamma -gamma $value
}

if [ $# -gt 1 ] && [ $# -lt 3 ]; then
    if [ $1 = "-g" ] || [ $1 = "--gamma" ]; then
    vga_gamma
    elif [ $1 = "-b" ] || [ $1 = "--brightness" ]; then
    vga_brightness
    else
    usage
    fi
else
    usage
fi