tazpanel rev 629

powersaving.cgi: add cpu governor update support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jul 07 19:59:19 2019 +0200 (3 months ago)
parents c56eca297b15
children 6cd2b37d9afc
files hardware.cgi po/fr.po powersaving.cgi
line diff
     1.1 --- a/hardware.cgi	Sun Jul 07 11:52:21 2019 +0200
     1.2 +++ b/hardware.cgi	Sun Jul 07 19:59:19 2019 +0200
     1.3 @@ -342,7 +342,7 @@
     1.4  
     1.5  		# CPU frequency
     1.6  		if [ -n "$(ls /sys/devices/system/cpu/*/cpufreq/cpuinfo_cur_freq 2>/dev/null)" ]; then
     1.7 -			echo "<p><span data-icon=\"@daemons@\">$(sed '/name/!ds|.*: ||;q' /proc/cpuinfo) :</span>"
     1.8 +			echo "<p><span data-icon=\"@cpu@\">$(sed '/name/!d;s|.*: ||;s|(TM)|™|;s|(R)|®|;q' /proc/cpuinfo) :</span>"
     1.9  			for f in /sys/devices/system/cpu/*/cpufreq/cpuinfo_cur_freq; do
    1.10  				awk '{ print $1/1000 "MHz" }' < $f
    1.11  			done
     2.1 --- a/po/fr.po	Sun Jul 07 11:52:21 2019 +0200
     2.2 +++ b/po/fr.po	Sun Jul 07 19:59:19 2019 +0200
     2.3 @@ -271,7 +271,7 @@
     2.4  
     2.5  #: boot.cgi:409 floppy.cgi:289
     2.6  msgid "set /dev/cdrom for a physical CD-ROM"
     2.7 -msgstr "Mettre à jour /dev/cdrom pour indiquer le lecteur de CD-ROM"
     2.8 +msgstr "Mettre /dev/cdrom pour indiquer le lecteur de CD-ROM"
     2.9  
    2.10  #: boot.cgi:412
    2.11  msgid "Working directory"
     3.1 --- a/powersaving.cgi	Sun Jul 07 11:52:21 2019 +0200
     3.2 +++ b/powersaving.cgi	Sun Jul 07 19:59:19 2019 +0200
     3.3 @@ -17,6 +17,15 @@
     3.4  		exit
     3.5  esac
     3.6  
     3.7 +for p in $(POST); do
     3.8 +	case "$p" in
     3.9 +	governor)
    3.10 +		for i in /sys/devices/system/cpu/cpu*/cpufreq ; do
    3.11 +			echo "$(POST $p)" > $i/scaling_governor
    3.12 +		done
    3.13 +	esac
    3.14 +done
    3.15 +
    3.16  header
    3.17  
    3.18  TITLE=$(_ 'Hardware')
    3.19 @@ -123,6 +132,7 @@
    3.20  [ "$multiplier" -ne 1 ] && cpu="$multiplier × $(echo "$cpu" | head -n1)"
    3.21  
    3.22  freq=$(awk -F: 'BEGIN{N=0}$1~"MHz"{printf "%d:<b>%s</b>MHz ",N,$2; N++}' /proc/cpuinfo)
    3.23 +cpufreq=/sys/devices/system/cpu/cpu0/cpufreq
    3.24  
    3.25  cat <<EOT
    3.26  <section>
    3.27 @@ -133,12 +143,27 @@
    3.28  automatically depending on the system load, in response to ACPI events, or \
    3.29  manually by userspace programs.")</div>
    3.30  
    3.31 +	<form method="post" class="wide">
    3.32 +
    3.33  	<table class="wide zebra">
    3.34  		<tr><td>$(_ 'Model name')</td><td>$cpu</td></tr>
    3.35  		<tr><td>$(_ 'Current frequency')</td><td>$freq</td></tr>
    3.36 -		<tr><td>$(_ 'Current driver')</td><td>$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver')
    3.37 -		<tr><td>$(_ 'Current governor')</td><td>$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor')
    3.38 +		<tr><td>$(_ 'Current driver')</td><td>$(cat "$cpufreq/scaling_driver")
    3.39 +		<tr><td>$(_ 'Current governor')</td><td><select name="governor">
    3.40 +EOT
    3.41 +
    3.42 +for i in $(cat "$cpufreq/scaling_available_governors"); do
    3.43 +	sel=""; [ $i = $(cat "$cpufreq/scaling_governor") ] && sel=" selected"
    3.44 +	echo "			<option$sel>$i</option>"
    3.45 +done
    3.46 +
    3.47 +cat <<EOT
    3.48 +		</select></td></tr>
    3.49  	</table>
    3.50 +		<footer>
    3.51 +			<button type="submit" data-icon="@ok@">$(_ 'Change')</button>
    3.52 +		</footer>
    3.53 +	</form>
    3.54  </section>
    3.55  EOT
    3.56