tazpanel annotate powersaving.cgi @ rev 501

*.cgi: Implement TazPanel title and sub-title; hardware.cgi: fix and improve modules search; index.cgi: complex code using awk was prevented 'make pot' to collect all messages, fix terminal history removing; tazpanel.js: disable buttons when no packages selected (pkgs.cgi: up / search / category lists); network.cgi: complex comment was prevented 'make pot' to collect all messages; powersaving.cgi: starting development; *.po: rebuild; tazpanel.ttf: add messages icons, so remove all the style/png images and change libtazpanel; *.css: title and sub-title, messages icons; test.cgi: add new icons.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Jun 08 04:32:19 2015 +0300 (2015-06-08)
parents
children d7b7403d5f2a
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
al@501 11 header
al@501 12
al@501 13 TITLE=$(_ 'Hardware')
al@501 14
al@501 15 xhtml_header "$(_ 'Power saving')"
al@501 16
al@501 17 ## DPMS ##
al@501 18 cat <<EOT
al@501 19 <section>
al@501 20 <header>
al@501 21 <span data-icon="display">DPMS (Display Power Management Signaling)</span>
al@501 22 </header>
al@501 23
al@501 24 <div>$(_ "DPMS enables power saving behaviour of monitors when the computer is not in use.")</div>
al@501 25 <form method="post" class="wide">
al@501 26 <input type="hidden" name="powersaving" value="set"/>
al@501 27 EOT
al@501 28
al@501 29 monitor_conf='/etc/X11/xorg.conf.d/50-Monitor.conf'
al@501 30 if [ ! -s "$monitor_conf" ]; then
al@501 31 # Config is absent, so create it
al@501 32 cat > "$monitor_conf" <<EOT
al@501 33 Section "Monitor"
al@501 34 Identifier "Monitor0"
al@501 35 VendorName "Monitor Vendor"
al@501 36 ModelName "Monitor Model"
al@501 37 Option "DPMS" "true"
al@501 38 EndSection
al@501 39 EOT
al@501 40 fi
al@501 41
al@501 42 cat <<EOT
al@501 43 <table class="wide zebra">
al@501 44 <thead>
al@501 45 <tr><td>$(_ 'Identifier')</td>
al@501 46 <td>$(_ 'Vendor name')</td>
al@501 47 <td>$(_ 'Model name')</td>
al@501 48 <td>$(_ 'DPMS enabled')</td>
al@501 49 </tr>
al@501 50 </thead>
al@501 51 EOT
al@501 52
al@501 53 awk -F\" '{
al@501 54 if ($1 ~ /^Section/) { I = V = M = D = ""; }
al@501 55 if ($1 ~ /Identifier/) { I = $2; }
al@501 56 if ($1 ~ /VendorName/) { V = $2; }
al@501 57 if ($1 ~ /ModelName/) { M = $2; }
al@501 58 if ($1 ~ /Option/ && $2 ~ /DPMS/) { D = $4; }
al@501 59 if ($1 ~ /EndSection/) {
al@501 60 if (D == "false") { D = ""; } else { D = "checked"; }
al@501 61 printf "<tr><td data-icon=\"display\">%s</td><td>%s</td><td>%s</td><td>", I, V, M;
al@501 62 printf "<label><input type=\"checkbox\" name=\"%s\" %s/>DPMS</label>", I, D;
al@501 63 printf "</td></tr>\n";
al@501 64 }
al@501 65 }' $monitor_conf
al@501 66
al@501 67 layout_conf='/etc/X11/xorg.conf.d/10-ServerLayout.conf'
al@501 68
al@501 69 cat <<EOT
al@501 70 </table>
al@501 71 <input type="hidden" name="ids" value="$(
al@501 72 awk -F\" '$1 ~ /Identifier/ { printf "%s ", $2; }' $monitor_conf)"/>
al@501 73
al@501 74 <table>
al@501 75 <tr><td>
al@501 76 <fieldset>
al@501 77 <legend>$(_ 'DPMS times (in minutes):')</legend>
al@501 78 <table>
al@501 79 <tr><td>Standby Time</td>
al@501 80 <td><input type="number" name="StandbyTime" value="10"/></td></tr>
al@501 81 <tr><td>Suspend Time</td>
al@501 82 <td><input type="number" name="SuspendTime" value="20"/></td></tr>
al@501 83 <tr><td>Off Time</td>
al@501 84 <td><input type="number" name="OffTime" value="30"/></td></tr>
al@501 85 </table>
al@501 86 </fieldset>
al@501 87 </td>
al@501 88 <td style="vertical-align: top">
al@501 89 <fieldset>
al@501 90 <legend>$(_ 'Manual edit')</legend>
al@501 91 <a data-icon="conf" href="index.cgi?file=$monitor_conf">$(basename $monitor_conf)</a><br/>
al@501 92 <a data-icon="conf" href="index.cgi?file=$layout_conf">$(basename $layout_conf)</a>
al@501 93 </fieldset>
al@501 94 <pre>$(for i in $(POST); do echo "$i: " $(POST $i); done)</pre>
al@501 95 </td>
al@501 96 </tr>
al@501 97 </table>
al@501 98 <footer>
al@501 99 <button type="submit" data-icon="ok">$(_ 'Change')</button>
al@501 100 </footer>
al@501 101 </form>
al@501 102 </section>
al@501 103 EOT
al@501 104
al@501 105
al@501 106 ## CPU ##
al@501 107
al@501 108 cpu=$(awk -F: '$1 ~ "model name" {
al@501 109 gsub(/\(TM\)/,"™",$2); gsub(/\(R\)/,"®",$2);
al@501 110 split($2,c,"@");
al@501 111 print "<span data-icon=\"cpu\">" c[1] "</span>";
al@501 112 }' /proc/cpuinfo)
al@501 113 multiplier=$(echo "$cpu" | wc -l)
al@501 114 [ "$multiplier" -ne 1 ] && cpu="$multiplier × $(echo "$cpu" | head -n1)"
al@501 115
al@501 116 freq=$(awk -F: 'BEGIN{N=0}$1~"MHz"{printf "%d:<b>%s</b>MHz ",N,$2; N++}' /proc/cpuinfo)
al@501 117
al@501 118 cat <<EOT
al@501 119 <section>
al@501 120 <header><span data-icon="cpu">$(_ 'CPU')</span></header>
al@501 121
al@501 122 <div>$(_ "CPU frequency scaling enables the operating system to scale the \
al@501 123 CPU frequency up or down in order to save power. CPU frequencies can be scaled \
al@501 124 automatically depending on the system load, in responce to ACPI events, or \
al@501 125 manually by userspace programs.")</div>
al@501 126
al@501 127 <table class="wide zebra">
al@501 128 <tr><td>$(_ 'Model name')</td><td>$cpu</td></tr>
al@501 129 <tr><td>$(_ 'Current frequency')</td><td>$freq</td></tr>
al@501 130 <tr><td>$(_ 'Current driver')</td><td>$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver')
al@501 131 <tr><td>$(_ 'Current governor')</td><td>$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor')
al@501 132 </table>
al@501 133 </section>
al@501 134 EOT
al@501 135
al@501 136 # As of Kernel 3.4, the native CPU module is loaded automatically.
al@501 137 if [ -d "/lib/modules/$(uname -r)/kernel/drivers/cpufreq" ]; then
al@501 138 cd /lib/modules/$(uname -r)/kernel/drivers/cpufreq
al@501 139 cat <<EOT
al@501 140 <section>
al@501 141 <header>$(_ 'Kernel modules')</header>
al@501 142 <table class="wide zebra summary">
al@501 143 <thead>
al@501 144 <tr><td>$(_ 'Module')</td>
al@501 145 <td>$(_ 'Description')</td>
al@501 146 </tr>
al@501 147 </thead>
al@501 148 EOT
al@501 149 lsmod="$(lsmod | awk '{printf "%s " $1}') "
al@501 150
al@501 151 for module in $(ls | grep -v 'mperf\|speedstep-lib'); do
al@501 152 module="${module%.ko.xz}"; module="${module//-/_}"
al@501 153 if echo $lsmod | grep -q " $module "; then icon='ok'; else icon='cancel'; fi
al@501 154 echo "<tr><td><span data-icon=\"$icon\">$module</span></td><td>"
al@501 155 modinfo $module | awk -F: '$1=="description"{
al@501 156 gsub(/\(TM\)/,"™",$2); gsub(/\(R\)/,"®",$2);
al@501 157 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 158 print $2}'
al@501 159 echo "</td></tr>"
al@501 160 done
al@501 161 cat <<EOT
al@501 162 </table>
al@501 163 </section>
al@501 164 EOT
al@501 165 fi
al@501 166
al@501 167 xhtml_footer
al@501 168 exit 0