Skip to content

Commit

Permalink
powersaving.cgi: add cpu governor update support
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Bellard committed Jul 7, 2019
1 parent 47cb983 commit 768fc98
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hardware.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ EOT

# CPU frequency
if [ -n "$(ls /sys/devices/system/cpu/*/cpufreq/cpuinfo_cur_freq 2>/dev/null)" ]; then
echo "<p><span data-icon=\"@daemons@\">$(sed '/name/!ds|.*: ||;q' /proc/cpuinfo) :</span>"
echo "<p><span data-icon=\"@cpu@\">$(sed '/name/!d;s|.*: ||;s|(TM)|™|;s|(R)|®|;q' /proc/cpuinfo) :</span>"
for f in /sys/devices/system/cpu/*/cpufreq/cpuinfo_cur_freq; do
awk '{ print $1/1000 "MHz" }' < $f
done
Expand Down
2 changes: 1 addition & 1 deletion po/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ msgstr "Chemin complet de l'image ISO"

#: boot.cgi:409 floppy.cgi:289
msgid "set /dev/cdrom for a physical CD-ROM"
msgstr "Mettre à jour /dev/cdrom pour indiquer le lecteur de CD-ROM"
msgstr "Mettre /dev/cdrom pour indiquer le lecteur de CD-ROM"

#: boot.cgi:412
msgid "Working directory"
Expand Down
29 changes: 27 additions & 2 deletions powersaving.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ EOT
exit
esac

for p in $(POST); do
case "$p" in
governor)
for i in /sys/devices/system/cpu/cpu*/cpufreq ; do
echo "$(POST $p)" > $i/scaling_governor
done
esac
done

header

TITLE=$(_ 'Hardware')
Expand Down Expand Up @@ -123,6 +132,7 @@ multiplier=$(echo "$cpu" | wc -l)
[ "$multiplier" -ne 1 ] && cpu="$multiplier × $(echo "$cpu" | head -n1)"

freq=$(awk -F: 'BEGIN{N=0}$1~"MHz"{printf "%d:<b>%s</b>MHz ",N,$2; N++}' /proc/cpuinfo)
cpufreq=/sys/devices/system/cpu/cpu0/cpufreq

cat <<EOT
<section>
Expand All @@ -133,12 +143,27 @@ CPU frequency up or down in order to save power. CPU frequencies can be scaled \
automatically depending on the system load, in response to ACPI events, or \
manually by userspace programs.")</div>
<form method="post" class="wide">
<table class="wide zebra">
<tr><td>$(_ 'Model name')</td><td>$cpu</td></tr>
<tr><td>$(_ 'Current frequency')</td><td>$freq</td></tr>
<tr><td>$(_ 'Current driver')</td><td>$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver')
<tr><td>$(_ 'Current governor')</td><td>$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor')
<tr><td>$(_ 'Current driver')</td><td>$(cat "$cpufreq/scaling_driver")
<tr><td>$(_ 'Current governor')</td><td><select name="governor">
EOT

for i in $(cat "$cpufreq/scaling_available_governors"); do
sel=""; [ $i = $(cat "$cpufreq/scaling_governor") ] && sel=" selected"
echo " <option$sel>$i</option>"
done

cat <<EOT
</select></td></tr>
</table>
<footer>
<button type="submit" data-icon="@ok@">$(_ 'Change')</button>
</footer>
</form>
</section>
EOT

Expand Down

0 comments on commit 768fc98

Please # to comment.