Last active
August 29, 2015 14:14
-
-
Save astronasutarou/ef51249f25632149d130 to your computer and use it in GitHub Desktop.
Ubuntu 14.04 で LCD の明るさをコマンドラインから変えたい ref: http://qiita.com/xr0038/items/7a22a63f121ce2c205c7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# @brief Change LCD brightness | |
# | |
# Change the brightness of the current LCD via command line. | |
# You should be a root to run this script. | |
# | |
# @usage | |
# ./brightness value | |
# | |
# @param value | |
# A relative brightness. The max brightness is when value = 100. | |
# If value > 100, it is regarded as value = 100. The minimum | |
# brightness is set when value = 0. But this means a LCD blackout. | |
# Thus, value smaller than 20 is ignored and set value = 20. | |
# Non-numeric input is regarded as value = 20. | |
## | |
usage () { | |
echo "usage:" >&2 | |
echo " brightness value" >&2 | |
echo " value is an integer number between 20 and 100." >&2 | |
exit 1; | |
} | |
## No argument, then show usage and exit. | |
[ -z "${@}" ] && usage | |
## Parse the first argument. Non-numeric input is zero. | |
VALUE=$(echo ${1:?} | awk '{print $1*1}') | |
[ ${VALUE} -gt 100 ] && VALUE=100 | |
[ ${VALUE} -lt 20 ] && VALUE=20 | |
PREFIX="/sys/class/backlight/intel_backlight" | |
MAX_V=$(cat ${PREFIX}/max_brightness) | |
VALUE=$(echo "${MAX_V} * ${VALUE} / 100" | bc) | |
echo ${VALUE} | sudo tee ${PREFIX}/brightness >/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install xbacklight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xbacklight -set 50 # brightness を 50 に設定 | |
xbacklight -inc 10 # brightness を 10% あげる | |
xbacklight -dec 10 # brightness を 10% さげる |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xrandr -q | grep " connected" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xrandr --output LVDS1 --brightness 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 400 > /sys/class/backlight/intel_backlight/brightness |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brightness.sh 100 # 輝度を最大に設定 | |
brightness.sh 0 # 輝度を最小に設定 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment