tazpanel annotate powersaving.cgi @ rev 516

Makefile add install_extra
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Aug 02 20:24:23 2015 +0200 (2015-08-02)
parents 3117717c007d
children a15373a181ff
rev   line source
al@501 1 #!/bin/sh
al@501 2 #
al@501 3 # Hardware / power saving
al@501 4 #
al@501 5 # Copyright (C) 2011-2015 SliTaz GNU/Linux - BSD License
al@501 6 #
al@501 7
al@501 8 # Common functions from libtazpanel
al@501 9 . lib/libtazpanel
al@501 10 get_config
pascal@516 11
pascal@516 12 case "$1" in
pascal@516 13 menu)
pascal@516 14 cat <<EOT
pascal@516 15 <li><a data-icon="display" href="powersaving.cgi" data-root>$(_ 'Power saving')</a></li>
pascal@516 16 EOT
pascal@516 17 exit
pascal@516 18 esac
pascal@516 19
al@501 20 header
al@501 21
al@501 22 TITLE=$(_ 'Hardware')
al@501 23
al@501 24 xhtml_header "$(_ 'Power saving')"
al@501 25
al@501 26 ## DPMS ##
al@501 27 cat <<EOT
al@501 28 <section>
al@501 29 <header>
al@501 30 <span data-icon="display">DPMS (Display Power Management Signaling)</span>
al@501 31 </header>
al@501 32
al@501 33 <div>$(_ "DPMS enables power saving behaviour of monitors when the computer is not in use.")</div>
al@501 34 <form method="post" class="wide">
al@501 35 <input type="hidden" name="powersaving" value="set"/>
al@501 36 EOT
al@501 37
al@501 38 monitor_conf='/etc/X11/xorg.conf.d/50-Monitor.conf'
al@501 39 if [ ! -s "$monitor_conf" ]; then
al@501 40 # Config is absent, so create it
al@501 41 cat > "$monitor_conf" <<EOT
al@501 42 Section "Monitor"
al@501 43 Identifier "Monitor0"
al@501 44 VendorName "Monitor Vendor"
al@501 45 ModelName "Monitor Model"
al@501 46 Option "DPMS" "true"
al@501 47 EndSection
al@501 48 EOT
al@501 49 fi
al@501 50
al@501 51 cat <<EOT
al@501 52 <table class="wide zebra">
al@501 53 <thead>
al@501 54 <tr><td>$(_ 'Identifier')</td>
al@501 55 <td>$(_ 'Vendor name')</td>
al@501 56 <td>$(_ 'Model name')</td>
al@501 57 <td>$(_ 'DPMS enabled')</td>
al@501 58 </tr>
al@501 59 </thead>
al@501 60 EOT
al@501 61
al@501 62 awk -F\" '{
al@501 63 if ($1 ~ /^Section/) { I = V = M = D = ""; }
al@501 64 if ($1 ~ /Identifier/) { I = $2; }
al@501 65 if ($1 ~ /VendorName/) { V = $2; }
al@501 66 if ($1 ~ /ModelName/) { M = $2; }
al@501 67 if ($1 ~ /Option/ && $2 ~ /DPMS/) { D = $4; }
al@501 68 if ($1 ~ /EndSection/) {
al@501 69 if (D == "false") { D = ""; } else { D = "checked"; }
al@501 70 printf "<tr><td data-icon=\"display\">%s</td><td>%s</td><td>%s</td><td>", I, V, M;
al@501 71 printf "<label><input type=\"checkbox\" name=\"%s\" %s/>DPMS</label>", I, D;
al@501 72 printf "</td></tr>\n";
al@501 73 }
al@501 74 }' $monitor_conf
al@501 75
al@501 76 layout_conf='/etc/X11/xorg.conf.d/10-ServerLayout.conf'
al@501 77
al@501 78 cat <<EOT
al@501 79 </table>
al@501 80 <input type="hidden" name="ids" value="$(
al@501 81 awk -F\" '$1 ~ /Identifier/ { printf "%s ", $2; }' $monitor_conf)"/>
al@501 82
al@501 83 <table>
al@501 84 <tr><td>
al@501 85 <fieldset>
al@501 86 <legend>$(_ 'DPMS times (in minutes):')</legend>
al@501 87 <table>
al@501 88 <tr><td>Standby Time</td>
al@501 89 <td><input type="number" name="StandbyTime" value="10"/></td></tr>
al@501 90 <tr><td>Suspend Time</td>
al@501 91 <td><input type="number" name="SuspendTime" value="20"/></td></tr>
al@501 92 <tr><td>Off Time</td>
al@501 93 <td><input type="number" name="OffTime" value="30"/></td></tr>
al@501 94 </table>
al@501 95 </fieldset>
al@501 96 </td>
al@501 97 <td style="vertical-align: top">
al@501 98 <fieldset>
al@501 99 <legend>$(_ 'Manual edit')</legend>
al@501 100 <a data-icon="conf" href="index.cgi?file=$monitor_conf">$(basename $monitor_conf)</a><br/>
al@501 101 <a data-icon="conf" href="index.cgi?file=$layout_conf">$(basename $layout_conf)</a>
al@501 102 </fieldset>
al@501 103 <pre>$(for i in $(POST); do echo "$i: " $(POST $i); done)</pre>
al@501 104 </td>
al@501 105 </tr>
al@501 106 </table>
al@501 107 <footer>
al@501 108 <button type="submit" data-icon="ok">$(_ 'Change')</button>
al@501 109 </footer>
al@501 110 </form>
al@501 111 </section>
al@501 112 EOT
al@501 113
al@501 114
al@501 115 ## CPU ##
al@501 116
al@501 117 cpu=$(awk -F: '$1 ~ "model name" {
al@501 118 gsub(/\(TM\)/,"™",$2); gsub(/\(R\)/,"®",$2);
al@501 119 split($2,c,"@");
al@501 120 print "<span data-icon=\"cpu\">" c[1] "</span>";
al@501 121 }' /proc/cpuinfo)
al@501 122 multiplier=$(echo "$cpu" | wc -l)
al@501 123 [ "$multiplier" -ne 1 ] && cpu="$multiplier × $(echo "$cpu" | head -n1)"
al@501 124
al@501 125 freq=$(awk -F: 'BEGIN{N=0}$1~"MHz"{printf "%d:<b>%s</b>MHz ",N,$2; N++}' /proc/cpuinfo)
al@501 126
al@501 127 cat <<EOT
al@501 128 <section>
al@501 129 <header><span data-icon="cpu">$(_ 'CPU')</span></header>
al@501 130
al@501 131 <div>$(_ "CPU frequency scaling enables the operating system to scale the \
al@501 132 CPU frequency up or down in order to save power. CPU frequencies can be scaled \
al@501 133 automatically depending on the system load, in responce to ACPI events, or \
al@501 134 manually by userspace programs.")</div>
al@501 135
al@501 136 <table class="wide zebra">
al@501 137 <tr><td>$(_ 'Model name')</td><td>$cpu</td></tr>
al@501 138 <tr><td>$(_ 'Current frequency')</td><td>$freq</td></tr>
al@501 139 <tr><td>$(_ 'Current driver')</td><td>$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver')
al@501 140 <tr><td>$(_ 'Current governor')</td><td>$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor')
al@501 141 </table>
al@501 142 </section>
al@501 143 EOT
al@501 144
al@501 145 # As of Kernel 3.4, the native CPU module is loaded automatically.
al@501 146 if [ -d "/lib/modules/$(uname -r)/kernel/drivers/cpufreq" ]; then
al@501 147 cd /lib/modules/$(uname -r)/kernel/drivers/cpufreq
al@501 148 cat <<EOT
al@501 149 <section>
al@501 150 <header>$(_ 'Kernel modules')</header>
al@501 151 <table class="wide zebra summary">
al@501 152 <thead>
al@501 153 <tr><td>$(_ 'Module')</td>
al@501 154 <td>$(_ 'Description')</td>
al@501 155 </tr>
al@501 156 </thead>
al@501 157 EOT
al@501 158 lsmod="$(lsmod | awk '{printf "%s " $1}') "
al@501 159
al@501 160 for module in $(ls | grep -v 'mperf\|speedstep-lib'); do
al@501 161 module="${module%.ko.xz}"; module="${module//-/_}"
al@501 162 if echo $lsmod | grep -q " $module "; then icon='ok'; else icon='cancel'; fi
al@501 163 echo "<tr><td><span data-icon=\"$icon\">$module</span></td><td>"
al@501 164 modinfo $module | awk -F: '$1=="description"{
al@501 165 gsub(/\(TM\)/,"™",$2); gsub(/\(R\)/,"®",$2);
al@501 166 gsub(/VIA|C7|Cyrix|MediaGX|NatSemi|Geode|Transmeta|Crusoe|Efficeon|Pentium™ 4|Xeon™|AMD|K6-2\+|K6-3\+|K7|Athlon 64|Opteron|Intel/,"<b>&</b>",$2);
al@501 167 print $2}'
al@501 168 echo "</td></tr>"
al@501 169 done
al@501 170 cat <<EOT
al@501 171 </table>
al@501 172 </section>
al@501 173 EOT
al@501 174 fi
al@501 175
al@501 176 xhtml_footer
al@501 177 exit 0