-
-
Save yingted/6559149 to your computer and use it in GitHub Desktop.
Sync intel_backlight to acpi_video0 brightness using gamma.
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
#!/bin/sh | |
# Copyright (c) 2013, Ted Ying | |
# Permission is hereby granted, without written agreement and without | |
# license or royalty fees, to use, copy, modify, and distribute this | |
# software and its documentation for any purpose, provided that the | |
# above copyright notice and the following two paragraphs appear in | |
# all copies of this software. | |
# | |
# IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR | |
# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES | |
# ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN | |
# IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH | |
# DAMAGE. | |
# | |
# THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, | |
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
# FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS | |
# ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO | |
# PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
backlight_dir=/sys/class/backlight | |
src_dir=${backlight_dir}/acpi_video0 | |
dst_dir=${backlight_dir}/intel_backlight | |
gamma=2.5 | |
read src_max < "$src_dir/max_brightness" | |
read dst_max < "$dst_dir/max_brightness" | |
update(){ | |
read brightness < "$src_dir/brightness" | |
[ "$brightness" != "$prev_brighness" ] && echo "$brightness" || prev_brightness="$brightness" | |
} | |
{ | |
update | |
while inotifywait -qqe modify -t5 "$src_dir/brightness" || : | |
do | |
update | |
done | |
} | awk "{printf\"%d\\n\",.5+$dst_max*(\$1/$src_max)^$gamma;fflush()}" > "$dst_dir/brightness" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment