tazpanel annotate hardware.cgi @ rev 266
installer.cgi: add i18n, new pot and po files, fr.po updated
author | Dominique Corbex <domcox@slitaz.org> |
---|---|
date | Thu Mar 08 21:06:46 2012 +0100 (2012-03-08) |
parents | 8eb0c310c78c |
children | 72e9955ebdff |
rev | line source |
---|---|
pankso@46 | 1 #!/bin/sh |
pankso@46 | 2 # |
pankso@46 | 3 # Hardware part of TazPanel - Devices, drivers, printing |
pankso@46 | 4 # |
pankso@112 | 5 # Copyright (C) 2011 SliTaz GNU/Linux - BSD License |
pankso@46 | 6 # |
pankso@46 | 7 |
pankso@46 | 8 # Common functions from libtazpanel |
pankso@46 | 9 . lib/libtazpanel |
pankso@46 | 10 get_config |
pascal@81 | 11 header |
pankso@46 | 12 |
pankso@46 | 13 TITLE="- Hardware" |
pankso@46 | 14 |
pankso@46 | 15 # |
pankso@46 | 16 # Commands |
pankso@46 | 17 # |
pankso@46 | 18 |
pascal@81 | 19 case " $(GET) " in |
pascal@81 | 20 *\ print\ *) |
pankso@46 | 21 echo "TODO" ;; |
pankso@242 | 22 *\ detect\ *) |
pankso@242 | 23 # Front end for Tazhw |
pankso@242 | 24 # TODO: Add button to detect webcam, etc. Like in tazhw box. |
pankso@242 | 25 xhtml_header |
pankso@242 | 26 cat << EOT |
pankso@242 | 27 <div id="wrapper"> |
pankso@242 | 28 <h2>$(gettext "Detect hardware")</h2> |
pankso@242 | 29 <p>$(gettext "Detect PCI and USB hardware")</p> |
pankso@242 | 30 </div> |
pankso@242 | 31 EOT |
pankso@242 | 32 echo '<pre>' |
pankso@242 | 33 tazhw detect-pci |
pankso@242 | 34 echo '</pre>' |
pankso@242 | 35 echo '<pre>' |
pankso@242 | 36 tazhw detect-usb |
pankso@242 | 37 echo '</pre>' ;; |
pascal@81 | 38 *\ modules\ *|*\ modinfo\ *) |
pankso@46 | 39 xhtml_header |
pankso@46 | 40 cat << EOT |
pankso@46 | 41 <div id="wrapper"> |
pankso@66 | 42 <h2>`gettext "Kernel modules"`</h2> |
pankso@69 | 43 <div class="float-right"> |
pankso@69 | 44 <form method="get" action="$SCRIPT_NAME"> |
pankso@69 | 45 <input type="hidden" name="modules" /> |
pankso@69 | 46 <input type="text" name="search" /> |
pankso@69 | 47 </form> |
pankso@69 | 48 </div> |
pankso@242 | 49 <p>$(gettext "Manage, search or get information about the Linux kernel modules")</p> |
pankso@46 | 50 </div> |
pankso@46 | 51 EOT |
pankso@66 | 52 # Request may be modinfo output that we want in the page itself |
pascal@81 | 53 if [ -n "$(GET modinfo)" ]; then |
pascal@81 | 54 echo '<strong>' |
pascal@81 | 55 gettext "Detailed information for module: "; echo "$(GET modinfo)" |
pascal@81 | 56 echo '</strong>' |
pascal@81 | 57 echo '<pre>' |
pascal@81 | 58 modinfo $(GET modinfo) |
pascal@81 | 59 echo '</pre>' |
pascal@81 | 60 fi |
pascal@81 | 61 if [ -n "$(GET modprobe)" ]; then |
pascal@81 | 62 echo '<pre>' |
pascal@81 | 63 modprobe -v $(GET modprobe) |
pascal@81 | 64 echo '</pre>' |
pascal@81 | 65 fi |
pascal@81 | 66 if [ -n "$(GET rmmod)" ]; then |
pascal@81 | 67 echo "Removing" |
pascal@81 | 68 rmmod -w $(GET rmmod) |
pascal@81 | 69 fi |
pascal@81 | 70 if [ -n "$(GET search)" ]; then |
pascal@81 | 71 gettext "Matching result(s) for: "; echo "$(GET search)" |
pascal@81 | 72 echo '<pre>' |
pascal@81 | 73 modprobe -l | grep "$(GET search)" | while read line |
pascal@81 | 74 do |
pascal@81 | 75 name=$(basename $line) |
pascal@81 | 76 mod=${name%.ko.gz} |
pascal@81 | 77 echo "Module : <a href='$SCRIPT_NAME?modinfo=$mod'>$mod</a> " |
pascal@81 | 78 done |
pascal@81 | 79 echo '</pre>' |
pascal@81 | 80 fi |
pankso@46 | 81 cat << EOT |
pankso@46 | 82 `table_start` |
pankso@46 | 83 <tr class="thead"> |
pankso@46 | 84 <td>`gettext "Module"`</td> |
pankso@46 | 85 <td>`gettext "Size"`</td> |
pankso@46 | 86 <td>`gettext "Used"`</td> |
pankso@46 | 87 <td>`gettext "by"`</td> |
pankso@46 | 88 </tr> |
pankso@46 | 89 EOT |
pankso@46 | 90 # Get the list of modules and link to modinfo |
pankso@46 | 91 lsmod | grep ^[a-z] | while read MOD SIZE USED BY |
pankso@46 | 92 do |
pankso@46 | 93 cat << EOT |
pankso@46 | 94 <tr> |
pankso@46 | 95 <td><a href="$SCRIPT_NAME?modinfo=$MOD">$MOD</a></td> |
pankso@46 | 96 <td>$SIZE</td> |
pankso@46 | 97 <td>$USED</td> |
pankso@46 | 98 <td>`echo $BY | sed s/","/" "/g`</td> |
pankso@46 | 99 </tr> |
pankso@46 | 100 EOT |
pankso@46 | 101 done |
pankso@66 | 102 table_end ;; |
pankso@66 | 103 *) |
pascal@217 | 104 [ -n "$(GET brightness)" ] && |
pascal@262 | 105 echo -n $(GET brightness) > /sys/devices/virtual/backlight/$(GET dev)/brightness |
pascal@217 | 106 |
pankso@66 | 107 # |
pankso@66 | 108 # Default to summary with mounted filesystem, loaded modules |
pankso@66 | 109 # |
pankso@66 | 110 xhtml_header |
pankso@66 | 111 cat << EOT |
pankso@66 | 112 <div id="wrapper"> |
pankso@66 | 113 <h2>`gettext "Drivers & Devices"`</h2> |
pankso@66 | 114 <p>`gettext "Manage your computer hardware`</p> |
pascal@219 | 115 </div> |
pascal@219 | 116 <div> |
pascal@219 | 117 <a class="button" href="$SCRIPT_NAME?modules"> |
pascal@219 | 118 <img src="$IMAGES/tux.png" />Kernel modules</a> |
pankso@242 | 119 <a class="button" href="$SCRIPT_NAME?detect"> |
pankso@246 | 120 <img src="$IMAGES/monitor.png" />Detect PCI/USB</a> |
pascal@219 | 121 </div> |
pascal@219 | 122 |
pascal@219 | 123 <div id="wrapper"> |
pascal@217 | 124 EOT |
pascal@219 | 125 if [ -n "$(ls /proc/acpi/battery/*/info 2> /dev/null)" ]; then |
pascal@219 | 126 echo "<table>" |
pascal@219 | 127 for dev in /proc/acpi/battery/*; do |
pascal@219 | 128 grep ^present $dev/info | grep -q yes || continue |
pascal@219 | 129 design=$(sed '/design capacity:/!d;s/[^0-9]*\([0-9]*\).*/\1/' < $dev/info) |
pascal@219 | 130 remain=$(sed '/remaining capacity/!d;s/[^0-9]*\([0-9]*\).*/\1/' < $dev/state) |
pascal@219 | 131 rate=$(sed '/present rate/!d;s/[^0-9]*\([0-9]*\).*/\1/' < $dev/state) |
pascal@219 | 132 full=$(sed '/last full capacity/!d;s/[^0-9]*\([0-9]*\).*/\1/' < $dev/info) |
pankso@236 | 133 # FIXME |
pankso@236 | 134 #remtime=$(( ($remain * 60) / $rate )) |
pankso@236 | 135 #rempct=$(( ($remain * 100) / $full )) |
pascal@219 | 136 cat << EOT |
pascal@219 | 137 <tr> |
pascal@219 | 138 <td><img src="$IMAGES/battery.png" /> |
pascal@219 | 139 Battery $(grep "^battery type" $dev/info | sed 's/.*: *//') |
pascal@219 | 140 $(grep "^design capacity:" $dev/info | sed 's/.*: *//') </td> |
pascal@219 | 141 <td>health $(( (100*$full)/$design))%</td> |
pascal@219 | 142 EOT |
pascal@219 | 143 if grep -qis discharging $dev/state; then |
pascal@219 | 144 cat <<EOT |
pascal@219 | 145 <td class="pct"><div class="pct" |
pascal@219 | 146 style="width: $rempct%;">charge $rempct% - $(printf "%d:%02d" $(($remtime/60)) $(($remtime%60)))</div></td> |
pascal@219 | 147 EOT |
pascal@219 | 148 else |
pascal@219 | 149 cat <<EOT |
pascal@219 | 150 <td class="pct"><div class="pct" |
pascal@219 | 151 style="width: $rempct%;">recharging $rempct%</div></td> |
pascal@219 | 152 EOT |
pascal@219 | 153 fi |
pascal@219 | 154 done |
pascal@219 | 155 echo "</table>" |
pascal@219 | 156 fi |
pascal@262 | 157 if [ -n "$(ls /sys/devices/virtual/thermal/*/temp 2> /dev/null)" ]; then |
pascal@219 | 158 echo "Temperature: " |
pascal@262 | 159 for temp in /sys/devices/virtual/thermal/*/temp; do |
pascal@262 | 160 awk '{ print $1/1000 }' < $temp |
pascal@219 | 161 done |
pascal@219 | 162 fi |
pascal@262 | 163 if [ -n "$(ls /sys/devices/virtual/backlight/*/brightness 2> /dev/null)" ]; then |
pascal@217 | 164 cat <<EOT |
pascal@217 | 165 <form method="get" action="$SCRIPT_NAME"> |
pascal@217 | 166 EOT |
pascal@262 | 167 for dev in /sys/devices/virtual/backlight/*/brightness ; do |
pascal@262 | 168 name=$(echo $dev | sed 's|.*/backlight/\([^/]*\).*|\1|') |
pascal@217 | 169 cat <<EOT |
pascal@217 | 170 <input type="hidden" name="dev" value="$name" /> |
pascal@263 | 171 $(gettext "Brightness") \ |
pascal@263 | 172 $(sed 's/.*\.//;s/_*$//' < /sys/devices/virtual/backlight/$name/device/path): |
pascal@263 | 173 <select name="brightness" onchange="submit();"> |
pascal@217 | 174 EOT |
pascal@262 | 175 max=$(cat /sys/devices/virtual/backlight/$name/max_brightness) |
pascal@262 | 176 for i in $(seq 0 $max); do |
pascal@262 | 177 echo -n "<option value=\"$i\"" |
pascal@262 | 178 [ $i -eq $(cat /sys/devices/virtual/backlight/$name/actual_brightness) ] && |
pascal@262 | 179 echo -n " selected=\"selected\"" |
pascal@262 | 180 echo "> $(( (($i + 1) * 100) / ($max + 1) ))% </option>" |
pascal@262 | 181 done |
pascal@217 | 182 cat <<EOT |
pascal@217 | 183 </select> |
pascal@217 | 184 EOT |
pascal@217 | 185 done |
pascal@217 | 186 cat << EOT |
pascal@217 | 187 </form> |
pascal@217 | 188 EOT |
pascal@217 | 189 fi |
pascal@217 | 190 cat << EOT |
pankso@66 | 191 </div> |
pankso@152 | 192 |
pankso@152 | 193 <h3>$(gettext "Filesystem usage statistics")</h3> |
pankso@152 | 194 <pre> |
pankso@66 | 195 EOT |
pankso@152 | 196 fdisk -l | fgrep Disk |
pankso@66 | 197 echo '</pre>' |
pankso@153 | 198 # |
pankso@153 | 199 # Disk stats and management (mount, umount, heck) |
pankso@153 | 200 # |
pankso@153 | 201 table_start |
pankso@153 | 202 df_thead |
pankso@153 | 203 df -h | grep ^/dev | while read fs size used av pct mp |
pankso@153 | 204 do |
pankso@153 | 205 cat << EOT |
pankso@153 | 206 <tr> |
pankso@190 | 207 <td><img src="$IMAGES/harddisk.png" />${fs#/dev/}</td> |
pankso@153 | 208 <td>$size</td> |
pankso@153 | 209 <td>$av</td> |
pankso@153 | 210 <td class="pct"><div class="pct" |
pascal@217 | 211 style="width: $pct;">$used - $pct</div></td> |
pankso@153 | 212 <td>$mp</td> |
pankso@153 | 213 </tr> |
pankso@153 | 214 EOT |
pankso@153 | 215 done |
pankso@153 | 216 table_end |
pankso@152 | 217 echo "<h3>$(gettext "System memory")</h3>" |
pankso@152 | 218 echo '<pre>' |
pascal@219 | 219 free -m | sed \ |
pankso@152 | 220 -e s"#total.*\([^']\)#<span class='top'>\0</span>#"g \ |
pankso@152 | 221 -e s"#^[A-Z-].*:\([^']\)#<span class='sh-comment'>\0</span>#"g |
pankso@152 | 222 echo '</pre>' |
pankso@46 | 223 echo '<h3>lspci</h3>' |
pankso@46 | 224 echo '<pre>' |
pascal@155 | 225 lspci -k | sed \ |
pascal@155 | 226 -e s"#^[0-9].*\([^']\)#<span class='diff-at'>\0</span>#" \ |
pascal@155 | 227 -e s"#use: \(.*\)#use: <span class='diff-rm'>\1</span>#" |
pascal@61 | 228 echo '</pre>' |
pascal@61 | 229 echo '<h3>lsusb</h3>' |
pascal@61 | 230 echo '<pre>' |
pascal@61 | 231 lsusb |
pankso@46 | 232 echo '</pre>' |
pankso@46 | 233 ;; |
pankso@46 | 234 esac |
pankso@46 | 235 |
pankso@46 | 236 xhtml_footer |
pankso@46 | 237 exit 0 |