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
|
pascal@613
|
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
|
al@558
|
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
|
pascal@629
|
20 for p in $(POST); do
|
pascal@629
|
21 case "$p" in
|
pascal@629
|
22 governor)
|
pascal@629
|
23 for i in /sys/devices/system/cpu/cpu*/cpufreq ; do
|
pascal@637
|
24 POST $p > $i/scaling_governor
|
pascal@629
|
25 done
|
pascal@629
|
26 esac
|
pascal@629
|
27 done
|
pascal@629
|
28
|
al@501
|
29 header
|
al@501
|
30
|
al@501
|
31 TITLE=$(_ 'Hardware')
|
al@501
|
32
|
al@501
|
33 xhtml_header "$(_ 'Power saving')"
|
al@501
|
34
|
al@501
|
35 ## DPMS ##
|
al@501
|
36 cat <<EOT
|
al@501
|
37 <section>
|
al@501
|
38 <header>
|
al@558
|
39 <span data-icon="@display@">DPMS (Display Power Management Signaling)</span>
|
al@501
|
40 </header>
|
al@501
|
41
|
al@501
|
42 <div>$(_ "DPMS enables power saving behaviour of monitors when the computer is not in use.")</div>
|
al@501
|
43 <form method="post" class="wide">
|
al@501
|
44 <input type="hidden" name="powersaving" value="set"/>
|
al@501
|
45 EOT
|
al@501
|
46
|
al@501
|
47 monitor_conf='/etc/X11/xorg.conf.d/50-Monitor.conf'
|
al@501
|
48 if [ ! -s "$monitor_conf" ]; then
|
al@501
|
49 # Config is absent, so create it
|
al@501
|
50 cat > "$monitor_conf" <<EOT
|
al@501
|
51 Section "Monitor"
|
al@501
|
52 Identifier "Monitor0"
|
al@501
|
53 VendorName "Monitor Vendor"
|
al@501
|
54 ModelName "Monitor Model"
|
al@501
|
55 Option "DPMS" "true"
|
al@501
|
56 EndSection
|
al@501
|
57 EOT
|
al@501
|
58 fi
|
al@501
|
59
|
al@501
|
60 cat <<EOT
|
al@501
|
61 <table class="wide zebra">
|
al@501
|
62 <thead>
|
al@501
|
63 <tr><td>$(_ 'Identifier')</td>
|
al@501
|
64 <td>$(_ 'Vendor name')</td>
|
al@501
|
65 <td>$(_ 'Model name')</td>
|
al@501
|
66 <td>$(_ 'DPMS enabled')</td>
|
al@501
|
67 </tr>
|
al@501
|
68 </thead>
|
al@501
|
69 EOT
|
al@501
|
70
|
al@501
|
71 awk -F\" '{
|
al@501
|
72 if ($1 ~ /^Section/) { I = V = M = D = ""; }
|
al@501
|
73 if ($1 ~ /Identifier/) { I = $2; }
|
al@501
|
74 if ($1 ~ /VendorName/) { V = $2; }
|
al@501
|
75 if ($1 ~ /ModelName/) { M = $2; }
|
al@501
|
76 if ($1 ~ /Option/ && $2 ~ /DPMS/) { D = $4; }
|
al@501
|
77 if ($1 ~ /EndSection/) {
|
al@501
|
78 if (D == "false") { D = ""; } else { D = "checked"; }
|
al@558
|
79 printf "<tr><td data-icon=\"@display@\">%s</td><td>%s</td><td>%s</td><td>", I, V, M;
|
al@501
|
80 printf "<label><input type=\"checkbox\" name=\"%s\" %s/>DPMS</label>", I, D;
|
al@501
|
81 printf "</td></tr>\n";
|
al@501
|
82 }
|
al@501
|
83 }' $monitor_conf
|
al@501
|
84
|
al@501
|
85 layout_conf='/etc/X11/xorg.conf.d/10-ServerLayout.conf'
|
al@501
|
86
|
al@501
|
87 cat <<EOT
|
al@501
|
88 </table>
|
al@501
|
89 <input type="hidden" name="ids" value="$(
|
al@501
|
90 awk -F\" '$1 ~ /Identifier/ { printf "%s ", $2; }' $monitor_conf)"/>
|
al@501
|
91
|
al@501
|
92 <table>
|
al@501
|
93 <tr><td>
|
al@501
|
94 <fieldset>
|
al@501
|
95 <legend>$(_ 'DPMS times (in minutes):')</legend>
|
al@501
|
96 <table>
|
al@501
|
97 <tr><td>Standby Time</td>
|
al@501
|
98 <td><input type="number" name="StandbyTime" value="10"/></td></tr>
|
al@501
|
99 <tr><td>Suspend Time</td>
|
al@501
|
100 <td><input type="number" name="SuspendTime" value="20"/></td></tr>
|
al@501
|
101 <tr><td>Off Time</td>
|
al@501
|
102 <td><input type="number" name="OffTime" value="30"/></td></tr>
|
al@501
|
103 </table>
|
al@501
|
104 </fieldset>
|
al@501
|
105 </td>
|
al@501
|
106 <td style="vertical-align: top">
|
al@501
|
107 <fieldset>
|
al@501
|
108 <legend>$(_ 'Manual edit')</legend>
|
al@558
|
109 <a data-icon="@conf@" href="index.cgi?file=$monitor_conf">$(basename $monitor_conf)</a><br/>
|
al@558
|
110 <a data-icon="@conf@" href="index.cgi?file=$layout_conf">$(basename $layout_conf)</a>
|
al@501
|
111 </fieldset>
|
al@501
|
112 <pre>$(for i in $(POST); do echo "$i: " $(POST $i); done)</pre>
|
al@501
|
113 </td>
|
al@501
|
114 </tr>
|
al@501
|
115 </table>
|
al@501
|
116 <footer>
|
al@558
|
117 <button type="submit" data-icon="@ok@">$(_ 'Change')</button>
|
al@501
|
118 </footer>
|
al@501
|
119 </form>
|
al@501
|
120 </section>
|
al@501
|
121 EOT
|
al@501
|
122
|
al@501
|
123
|
al@501
|
124 ## CPU ##
|
al@501
|
125
|
al@501
|
126 cpu=$(awk -F: '$1 ~ "model name" {
|
al@501
|
127 gsub(/\(TM\)/,"™",$2); gsub(/\(R\)/,"®",$2);
|
al@501
|
128 split($2,c,"@");
|
al@558
|
129 print "<span data-icon=\"@cpu@\">" c[1] "</span>";
|
al@501
|
130 }' /proc/cpuinfo)
|
al@501
|
131 multiplier=$(echo "$cpu" | wc -l)
|
al@501
|
132 [ "$multiplier" -ne 1 ] && cpu="$multiplier × $(echo "$cpu" | head -n1)"
|
al@501
|
133
|
al@501
|
134 freq=$(awk -F: 'BEGIN{N=0}$1~"MHz"{printf "%d:<b>%s</b>MHz ",N,$2; N++}' /proc/cpuinfo)
|
pascal@629
|
135 cpufreq=/sys/devices/system/cpu/cpu0/cpufreq
|
al@501
|
136
|
al@501
|
137 cat <<EOT
|
al@501
|
138 <section>
|
al@558
|
139 <header><span data-icon="@cpu@">$(_ 'CPU')</span></header>
|
al@501
|
140
|
al@501
|
141 <div>$(_ "CPU frequency scaling enables the operating system to scale the \
|
al@501
|
142 CPU frequency up or down in order to save power. CPU frequencies can be scaled \
|
paul@584
|
143 automatically depending on the system load, in response to ACPI events, or \
|
al@501
|
144 manually by userspace programs.")</div>
|
al@501
|
145
|
pascal@629
|
146 <form method="post" class="wide">
|
pascal@629
|
147
|
al@501
|
148 <table class="wide zebra">
|
al@501
|
149 <tr><td>$(_ 'Model name')</td><td>$cpu</td></tr>
|
al@501
|
150 <tr><td>$(_ 'Current frequency')</td><td>$freq</td></tr>
|
pascal@629
|
151 <tr><td>$(_ 'Current driver')</td><td>$(cat "$cpufreq/scaling_driver")
|
pascal@629
|
152 <tr><td>$(_ 'Current governor')</td><td><select name="governor">
|
pascal@629
|
153 EOT
|
pascal@629
|
154
|
pascal@629
|
155 for i in $(cat "$cpufreq/scaling_available_governors"); do
|
pascal@629
|
156 sel=""; [ $i = $(cat "$cpufreq/scaling_governor") ] && sel=" selected"
|
pascal@629
|
157 echo " <option$sel>$i</option>"
|
pascal@629
|
158 done
|
pascal@629
|
159
|
pascal@629
|
160 cat <<EOT
|
pascal@629
|
161 </select></td></tr>
|
al@501
|
162 </table>
|
pascal@629
|
163 <footer>
|
pascal@629
|
164 <button type="submit" data-icon="@ok@">$(_ 'Change')</button>
|
pascal@629
|
165 </footer>
|
pascal@629
|
166 </form>
|
al@501
|
167 </section>
|
al@501
|
168 EOT
|
al@501
|
169
|
al@501
|
170 # As of Kernel 3.4, the native CPU module is loaded automatically.
|
al@501
|
171 if [ -d "/lib/modules/$(uname -r)/kernel/drivers/cpufreq" ]; then
|
al@501
|
172 cd /lib/modules/$(uname -r)/kernel/drivers/cpufreq
|
al@501
|
173 cat <<EOT
|
al@501
|
174 <section>
|
al@501
|
175 <header>$(_ 'Kernel modules')</header>
|
al@501
|
176 <table class="wide zebra summary">
|
al@501
|
177 <thead>
|
al@501
|
178 <tr><td>$(_ 'Module')</td>
|
al@501
|
179 <td>$(_ 'Description')</td>
|
al@501
|
180 </tr>
|
al@501
|
181 </thead>
|
al@501
|
182 EOT
|
al@501
|
183 lsmod="$(lsmod | awk '{printf "%s " $1}') "
|
al@501
|
184
|
al@501
|
185 for module in $(ls | grep -v 'mperf\|speedstep-lib'); do
|
al@501
|
186 module="${module%.ko.xz}"; module="${module//-/_}"
|
al@558
|
187 if echo $lsmod | grep -q " $module "; then icon='@ok@'; else icon='@cancel@'; fi
|
al@501
|
188 echo "<tr><td><span data-icon=\"$icon\">$module</span></td><td>"
|
al@501
|
189 modinfo $module | awk -F: '$1=="description"{
|
al@501
|
190 gsub(/\(TM\)/,"™",$2); gsub(/\(R\)/,"®",$2);
|
al@501
|
191 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
|
192 print $2}'
|
al@501
|
193 echo "</td></tr>"
|
al@501
|
194 done
|
al@501
|
195 cat <<EOT
|
al@501
|
196 </table>
|
al@501
|
197 </section>
|
al@501
|
198 EOT
|
al@501
|
199 fi
|
al@501
|
200
|
al@501
|
201 xhtml_footer
|
al@501
|
202 exit 0
|