tazpanel rev 262
hardware.cgi: get brightness from /sys
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Mar 04 18:02:22 2012 +0100 (2012-03-04) |
parents | 9bcc77055db5 |
children | 11fa97b09b7d |
files | hardware.cgi |
line diff
1.1 --- a/hardware.cgi Sun Mar 04 08:52:46 2012 +0100 1.2 +++ b/hardware.cgi Sun Mar 04 18:02:22 2012 +0100 1.3 @@ -102,7 +102,7 @@ 1.4 table_end ;; 1.5 *) 1.6 [ -n "$(GET brightness)" ] && 1.7 - echo -n $(GET brightness) > /proc/acpi/video/$(GET dev)/LCD/brightness 1.8 + echo -n $(GET brightness) > /sys/devices/virtual/backlight/$(GET dev)/brightness 1.9 1.10 # 1.11 # Default to summary with mounted filesystem, loaded modules 1.12 @@ -154,37 +154,29 @@ 1.13 done 1.14 echo "</table>" 1.15 fi 1.16 - if [ -n "$(ls /proc/acpi/thermal_zone/*/temperature 2> /dev/null)" ]; then 1.17 + if [ -n "$(ls /sys/devices/virtual/thermal/*/temp 2> /dev/null)" ]; then 1.18 echo "Temperature: " 1.19 - for temp in /proc/acpi/thermal_zone/*/temperature; do 1.20 - sed 's/.*://' < $temp 1.21 + for temp in /sys/devices/virtual/thermal/*/temp; do 1.22 + awk '{ print $1/1000 }' < $temp 1.23 done 1.24 fi 1.25 - if [ -n "$(ls /proc/acpi/video/*/LCD/brightness 2> /dev/null)" ]; then 1.26 + if [ -n "$(ls /sys/devices/virtual/backlight/*/brightness 2> /dev/null)" ]; then 1.27 cat <<EOT 1.28 <form method="get" action="$SCRIPT_NAME"> 1.29 EOT 1.30 - for dev in /proc/acpi/video/*/LCD/brightness ; do 1.31 - name=$(echo $dev | sed 's|.*/video/||;s|/LCD/.*||') 1.32 + for dev in /sys/devices/virtual/backlight/*/brightness ; do 1.33 + name=$(echo $dev | sed 's|.*/backlight/\([^/]*\).*|\1|') 1.34 cat <<EOT 1.35 <input type="hidden" name="dev" value="$name" /> 1.36 -$(gettext "LCD brightness") $name: <select name="brightness" onchange="submit();"> 1.37 +$(gettext "Brightness") ${name#acpi_}: <select name="brightness" onchange="submit();"> 1.38 EOT 1.39 - awk '{ 1.40 - if ($1 == "levels:") 1.41 - for (i = 2; i <= NF; i++) level[$i] = i 1.42 - if ($1 == "current:") current=$2 1.43 - } 1.44 - END { 1.45 - for (i in level) { 1.46 - s="<option value=\"" i "\"" 1.47 - if (current == i) s=s " selected=\"selected\"" 1.48 - s=s ">" i "%</option>" 1.49 - if (i == 100) last=s 1.50 - else print s 1.51 - } 1.52 - print last 1.53 - }' < $dev 1.54 + max=$(cat /sys/devices/virtual/backlight/$name/max_brightness) 1.55 + for i in $(seq 0 $max); do 1.56 + echo -n "<option value=\"$i\"" 1.57 + [ $i -eq $(cat /sys/devices/virtual/backlight/$name/actual_brightness) ] && 1.58 + echo -n " selected=\"selected\"" 1.59 + echo "> $(( (($i + 1) * 100) / ($max + 1) ))% </option>" 1.60 + done 1.61 cat <<EOT 1.62 </select> 1.63 EOT