Skip to content

Instantly share code, notes, and snippets.

@astronasutarou
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astronasutarou/ef51249f25632149d130 to your computer and use it in GitHub Desktop.
Save astronasutarou/ef51249f25632149d130 to your computer and use it in GitHub Desktop.
Ubuntu 14.04 で LCD の明るさをコマンドラインから変えたい ref: http://qiita.com/xr0038/items/7a22a63f121ce2c205c7
##
# @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
sudo apt-get install xbacklight
xbacklight -set 50 # brightness を 50 に設定
xbacklight -inc 10 # brightness を 10% あげる
xbacklight -dec 10 # brightness を 10% さげる
xrandr -q | grep " connected"
xrandr --output LVDS1 --brightness 0.5
echo 400 > /sys/class/backlight/intel_backlight/brightness
brightness.sh 100 # 輝度を最大に設定
brightness.sh 0 # 輝度を最小に設定
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment