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