slitaz-tools rev 298
Add WifiBox - Manage network wireless (essids, favorites, drivers)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Feb 22 22:03:46 2009 +0100 (2009-02-22) |
parents | f390590b62b4 |
children | 44848c607076 |
files | rootfs/usr/share/applications/wifibox.desktop tinyutils/wifibox |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/rootfs/usr/share/applications/wifibox.desktop Sun Feb 22 22:03:46 2009 +0100 1.3 @@ -0,0 +1,8 @@ 1.4 +[Desktop Entry] 1.5 +Encoding=UTF-8 1.6 +Name=Wireless networks connections 1.7 +Name[fr]=Connexions réseaux sans fil 1.8 +Exec=subox wifibox 1.9 +Icon=network-wireless 1.10 +Type=Application 1.11 +Categories=System;Application;
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/tinyutils/wifibox Sun Feb 22 22:03:46 2009 +0100 2.3 @@ -0,0 +1,618 @@ 2.4 +#!/bin/sh 2.5 +# 2.6 +# GTKdialog interface to manage wireless connection in a simple way. 2.7 +# Use tabs to indent, split commands from the GUI and use functions. 2.8 +# Favotites networks are also supported 2.9 +# 2.10 +# (c) 2009 SliTaz GNU/Linux - GNU gpl v3 2.11 +# 2.12 + 2.13 +# Export script path and other if needed so we can use them in 'quote'. 2.14 +export BIN=$0 2.15 +export FAVORITES_WIFI=/etc/wireless 2.16 +. /etc/network.conf 2.17 + 2.18 +# Wifibox is only for root. 2.19 +if test $(id -u) != 0 ; then 2.20 + exec subox wifibox 2.21 + exit 0 2.22 +fi 2.23 + 2.24 +# Sanity check 2.25 +[ -x /usr/sbin/iwconfig ] || tazpkg get-install wireless_tools 2.26 +[ -d $FAVORITES_WIFI ] || mkdir -p $FAVORITES_WIFI 2.27 +rm -f $FAVORITES_WIFI/any.conf 2.28 + 2.29 +# Catch ESSIDs and format output for GTK tree. We get the list off 2.30 +# network by Cell and without space. 2.31 +detect_wifi_networks() 2.32 +{ 2.33 + desktopbox notify "Scanning Wireless interface: $WIFI_INTERFACE" & 2.34 + if [ -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then 2.35 + ifconfig $WIFI_INTERFACE up 2.36 + for i in `iwlist $WIFI_INTERFACE scan | sed s/"Cell "/Cell-/ | grep "Cell-" | awk '{print $1}'` 2.37 + do 2.38 + SCAN=`iwlist $WIFI_INTERFACE scan | sed s/"Cell "/Cell-/ | grep -A 8 "$i"` 2.39 + ESSID=`echo $SCAN | cut -d '"' -f 2` 2.40 + if echo "$SCAN" | grep -q Quality; then 2.41 + QUALITY=`echo $SCAN | sed 's/.*Quality=\([^ ]*\).*/\1/' | sed 's/.*Quality:\([^ ]*\).*/\1/'` 2.42 + else 2.43 + QUALITY="-" 2.44 + fi 2.45 + ENCRYPTION=`echo $SCAN | sed 's/.*key:\([^ ]*\).*/\1/'` 2.46 + # Check encryption type 2.47 + if echo "$SCAN" | grep -q WPA; then 2.48 + ENCRYPTION="${ENCRYPTION} (WPA)" 2.49 + fi 2.50 + # Connected or not connected... 2.51 + if ifconfig | grep -A 1 $WIFI_INTERFACE | \ 2.52 + grep -q inet && iwconfig $WIFI_INTERFACE | \ 2.53 + grep ESSID | grep -q -w "$ESSID"; then 2.54 + STATUS=connected 2.55 + else 2.56 + STATUS="-" 2.57 + fi 2.58 + echo -n "" 2.59 + echo "$ESSID | $QUALITY | $ENCRYPTION | $STATUS" 2.60 + done 2.61 + fi 2.62 +} 2.63 + 2.64 +# cmdline functions 2.65 + 2.66 +# Configure /etc/network.conf and restart connexion with init script. 2.67 +start_wifi_connection() 2.68 +{ 2.69 + # Get tmp config created by connect_to_essid() if exist and set 2.70 + # empty value to clean config file. 2.71 + if [ -f /tmp/wifi.conf ]; then 2.72 + . /tmp/wifi.conf 2.73 + WIFI_MODE="" 2.74 + WIFI_IWCONFIG_ARGS="" 2.75 + WIFI_CHANNEL="" 2.76 + fi 2.77 + sed -i "s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/" \ 2.78 + /etc/network.conf 2.79 + sed -i "s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/" \ 2.80 + /etc/network.conf 2.81 + sed -i "s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/" \ 2.82 + /etc/network.conf 2.83 + sed -i "s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/" \ 2.84 + /etc/network.conf 2.85 + sed -i "s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/" \ 2.86 + /etc/network.conf 2.87 + sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" \ 2.88 + /etc/network.conf 2.89 + sed -i "s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/" \ 2.90 + /etc/network.conf 2.91 + sed -i "s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/" \ 2.92 + /etc/network.conf 2.93 + [ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid` 2.94 + ifconfig $WIFI_INTERFACE down 2.95 + iwconfig $WIFI_INTERFACE txpower auto 2.96 + /etc/init.d/network.sh restart 2.97 + # Remove tmp file (could be use to have wireless profiles) 2.98 + rm -f /tmp/wifi.conf 2.99 +} 2.100 + 2.101 +# We must spleep 4 sec to refresh networks list. 2.102 +stop_wifi_connexion() 2.103 +{ 2.104 + sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"no\"/ \ 2.105 + /etc/network.conf 2.106 + [ -x /etc/init.d/wpa_supplicant ] && /etc/init.d/wpa_supplicant stop 2.107 + ifconfig $WIFI_INTERFACE down 2.108 + iwconfig $WIFI_INTERFACE txpower off 2.109 + [ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid` 2.110 + sleep 4 2.111 +} 2.112 + 2.113 +# Favorites wireless networks use only 3 values: essid. key and type of 2.114 +# key 2.115 +FAVORITES_WIFI_list() 2.116 +{ 2.117 + for i in $FAVORITES_WIFI/*.conf 2.118 + do 2.119 + WIFI_ESSID="" 2.120 + WIFI_KEY="" 2.121 + WIFI_KEY_TYPE="" 2.122 + . "$i" 2.123 + [ -z "$WIFI_ESSID" ] && WIFI_ESSID="Bad config file: $i" 2.124 + [ -z "$WIFI_KEY_TYPE" ] && WIFI_KEY_TYPE="-" 2.125 + if [ -n "$WIFI_KEY" ]; then 2.126 + WIFI_KEY="********" 2.127 + else 2.128 + WIFI_KEY="-" 2.129 + fi 2.130 + echo "$WIFI_ESSID | $WIFI_KEY_TYPE | $WIFI_KEY" 2.131 + done 2.132 +} 2.133 + 2.134 +favorite_wifi_actions() 2.135 +{ 2.136 + cp -a $FAVORITES_WIFI/"$FAVORITE".conf /tmp/wifi.conf 2.137 + . /tmp/wifi.conf 2.138 + export CONNECT_FAVORITE=" 2.139 +<window title=\"Connect to: $WIFI_ESSID\" icon-name=\"network-wireless\"> 2.140 +<vbox> 2.141 + 2.142 + <text width-chars=\"54\"> 2.143 + <label> 2.144 +\" 2.145 +ESSID name: $WIFI_ESSID 2.146 +\" 2.147 + </label> 2.148 + </text> 2.149 + 2.150 + <hbox> 2.151 + <button> 2.152 + <label>Connect</label> 2.153 + <input file icon=\"forward\"></input> 2.154 + <action>$0 start_wifi_connection</action> 2.155 + <action type=\"exit\">exit</action> 2.156 + </button> 2.157 + <button> 2.158 + <label>Edit settings</label> 2.159 + <input file icon=\"accessories-text-editor\"></input> 2.160 + <action>leafpad $FAVORITES_WIFI/\"$FAVORITE\".conf</action> 2.161 + <action>rm -f /tmp/wifi.conf</action> 2.162 + <action type=\"exit\">exit</action> 2.163 + </button> 2.164 + <button> 2.165 + <label>Delete</label> 2.166 + <input file icon=\"gtk-delete\"></input> 2.167 + <action>rm -f $FAVORITES_WIFI/\"$FAVORITE\".conf</action> 2.168 + <action type=\"exit\">exit</action> 2.169 + </button> 2.170 + <button cancel></button> 2.171 + </hbox> 2.172 + 2.173 +</vbox> 2.174 +</window>" 2.175 + gtkdialog --center --program=CONNECT_FAVORITE >/dev/null 2.176 +} 2.177 + 2.178 +add_favorite_network_box() 2.179 +{ 2.180 + ADD_FAVORITE=' 2.181 +<window title="Add new favorite Wireless" icon-name="network-wireless"> 2.182 +<vbox> 2.183 + <text width-chars="54"> 2.184 + <label> 2.185 +" 2.186 +Please configure your new favorite Wireless network 2.187 +" 2.188 + </label> 2.189 + </text> 2.190 + <hbox> 2.191 + <text use-markup="true"> 2.192 + <label>"<b>ESSID:</b>"</label> 2.193 + </text> 2.194 + <entry> 2.195 + <variable>WIFI_ESSID</variable> 2.196 + </entry> 2.197 + </hbox> 2.198 + <hbox> 2.199 + <text use-markup="true"> 2.200 + <label>"<b>Key: </b>"</label> 2.201 + </text> 2.202 + <entry> 2.203 + <variable>WIFI_KEY</variable> 2.204 + </entry> 2.205 + </hbox> 2.206 + <hbox> 2.207 + <text use-markup="true"> 2.208 + <label>"<b>Key type:</b>"</label> 2.209 + </text> 2.210 + <combobox>' 2.211 + tmp="${ADD_FAVORITE}<item>$WIFI_KEY_TYPE</item>" 2.212 + for i in none WEP WPA any; do 2.213 + tmp=${tmp}"<item>$i</item>" 2.214 + done 2.215 + export ADD_FAVORITE=${tmp}' 2.216 + <variable>WIFI_KEY_TYPE</variable> 2.217 + </combobox> 2.218 + </hbox> 2.219 + <hbox> 2.220 + <button> 2.221 + <label>Add to list</label> 2.222 + <input file icon="forward"></input> 2.223 + <action>echo "# Wireless connection configuration." > $FAVORITES_WIFI/"$WIFI_ESSID".conf</action> 2.224 + <action>echo "#" >> /etc/wireless/"$WIFI_ESSID".conf</action> 2.225 + <action>echo "WIFI_ESSID=\"$WIFI_ESSID\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action> 2.226 + <action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action> 2.227 + <action>echo "WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action> 2.228 + <action type="exit">exit</action> 2.229 + </button> 2.230 + <button cancel></button> 2.231 + </hbox> 2.232 +</vbox> 2.233 +</window>' 2.234 + gtkdialog --center --program=ADD_FAVORITE #>/dev/null 2.235 +} 2.236 + 2.237 +# GUI functions 2.238 + 2.239 +helpbutton() 2.240 +{ 2.241 + local label; 2.242 + label="<label>$3</label>" 2.243 + [ -n "$3" ] || label="" 2.244 + cat << EOT 2.245 +<button> 2.246 + <input file icon="help"></input>$label 2.247 + <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry $2 -title "$1 help" -e "$(which $1) --help ; echo -e \\"----\\nENTER to continue...\\" && read close"</action> 2.248 +</button> 2.249 +EOT 2.250 +} 2.251 + 2.252 +manbutton() 2.253 +{ 2.254 + cat << EOT 2.255 +<button> 2.256 + <input file icon="browser"></input> 2.257 + <label>man</label> 2.258 + <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x24 -title "$2 man (q to quit)" -e ". /etc/profile; man $1 $2"</action> 2.259 +</button> 2.260 +EOT 2.261 +} 2.262 + 2.263 +# Independant dialog to connect on a wireless network. If encryption 2.264 +# is on we ask for the security key. 2.265 +connect_to_essid() 2.266 +{ 2.267 + SCAN=`iwlist $WIFI_INTERFACE scanning essid "$ESSID_LIST" | grep -A 6 "ESSID"` 2.268 + WIFI_ESSID="$ESSID_LIST" 2.269 + ENCRYPTION=`echo $SCAN | sed 's/.*key:\([^ ]*\).*/\1/'` 2.270 + # Create tmp file used by active_wifi_connexion() 2.271 + cat > /tmp/wifi.conf << _EOF_ 2.272 +# Wireless connexion configuration file. 2.273 +WIFI_ESSID="$ESSID_LIST" 2.274 +_EOF_ 2.275 + CONNECT_ESSID=" 2.276 +<window title=\"Connect to: $WIFI_ESSID\" icon-name=\"network-wireless\"> 2.277 +<vbox> 2.278 + <text width-chars=\"54\"> 2.279 + <label> 2.280 +\" 2.281 +Connect $WIFI_INTERFACE to: $WIFI_ESSID 2.282 +\" 2.283 + </label> 2.284 + </text>" 2.285 + # We mybe need a key to connect 2.286 + if [ "$ENCRYPTION" = "on" ] && [ "$ESSID_LIST" != "any" ]; then 2.287 + # WPA 2.288 + if echo "$SCAN" | grep -q WPA; then 2.289 + echo 'WIFI_KEY_TYPE="WPA"' >> /tmp/wifi.conf 2.290 + CONNECT_ESSID=${CONNECT_ESSID}' 2.291 + <hbox> 2.292 + <text use-markup="true"> 2.293 + <label>"<b>WPA Key:</b>"</label> 2.294 + </text> 2.295 + <entry> 2.296 + <input>. /etc/network.conf; echo "$WIFI_KEY"</input> 2.297 + <variable>WIFI_KEY</variable> 2.298 + </entry> 2.299 + </hbox>' 2.300 + else 2.301 + # WEP 2.302 + echo 'WIFI_KEY_TYPE="WEP"' >> /tmp/wifi.conf 2.303 + CONNECT_ESSID=${CONNECT_ESSID}' 2.304 + <hbox> 2.305 + <text use-markup="true"> 2.306 + <label>"<b>WEP Key:</b>"</label> 2.307 + </text> 2.308 + <entry> 2.309 + <input>. /etc/network.conf; echo "$WIFI_KEY"</input> 2.310 + <variable>WIFI_KEY</variable> 2.311 + </entry> 2.312 + </hbox>' 2.313 + fi 2.314 + else 2.315 + # No encryption 2.316 + echo 'WIFI_KEY=""' >> /tmp/wifi.conf 2.317 + echo 'WIFI_KEY_TYPE=""' >> /tmp/wifi.conf 2.318 + start_wifi_connection 2.319 + exit 0 2.320 + fi 2.321 + # Add key to config file so active_wifi_connexion() can use it. 2.322 + # WIFI_KEY is not exported if we quote with --> " 2.323 + export CONNECT_ESSID=${CONNECT_ESSID}' 2.324 + <hbox> 2.325 + <button> 2.326 + <label>Connect</label> 2.327 + <input file icon="forward"></input> 2.328 + <action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> /tmp/wifi.conf</action> 2.329 + <action>$BIN start_wifi_connection</action> 2.330 + <action type="exit">exit</action> 2.331 + </button> 2.332 + <button cancel></button> 2.333 + </hbox> 2.334 +</vbox> 2.335 +</window>' 2.336 + gtkdialog --center --program=CONNECT_ESSID #>/dev/null 2.337 +} 2.338 + 2.339 +# Wifibox start with Networks tab. 2.340 +box() 2.341 +{ 2.342 + WIFI_DIALOG=" 2.343 +<window title=\"Wireless manager\" icon-name=\"network-wireless\"> 2.344 +<vbox> 2.345 + 2.346 + <notebook labels=\"Networks|Favorites|Configuration|Drivers\"> 2.347 + 2.348 + <vbox> 2.349 + <tree icon=\"network-wireless\"> 2.350 + <width>500</width><height>160</height> 2.351 + <variable>ESSID_LIST</variable> 2.352 + <label>ESSID|Quality|Encryption|Status</label> 2.353 + <input>$0 detect_wifi_networks</input> 2.354 + <item icon=\"network-wireless\">any | * | off | (auto-connect)</item> 2.355 + <action>$0 connect_to_essid</action> 2.356 + <action>refresh:ESSID_LIST</action> 2.357 + <action>refresh:WIFI_ESSID</action> 2.358 + <action>refresh:WIFI_KEY</action> 2.359 + <action>refresh:WIFI_KEY_TYPE</action> 2.360 + </tree> 2.361 + <hbox> 2.362 + <text width-chars=\"50\"> 2.363 + <label> 2.364 +\"Please double clic on a network to connect or enter security key\" 2.365 + </label> 2.366 + </text> 2.367 + <button> 2.368 + <label>Refresh list</label> 2.369 + <input file icon=\"reload\"></input> 2.370 + <action>refresh:ESSID_LIST</action> 2.371 + </button> 2.372 + </hbox> 2.373 + </vbox>" 2.374 + 2.375 + # Favorites networks 2.376 + WIFI_DIALOG=${WIFI_DIALOG}" 2.377 + <vbox> 2.378 + <tree icon=\"network-wireless\"> 2.379 + <width>500</width><height>160</height> 2.380 + <variable>FAVORITE</variable> 2.381 + <label>ESSID|Key Type|Key status</label> 2.382 + <input>$0 FAVORITES_WIFI_list</input> 2.383 + <item icon=\"network-wireless\">any | - | -</item> 2.384 + <action>$0 favorite_wifi_actions</action> 2.385 + <action>refresh:FAVORITE</action> 2.386 + <action>refresh:ESSID_LIST</action> 2.387 + <action>refresh:WIFI_ESSID</action> 2.388 + <action>refresh:WIFI_KEY</action> 2.389 + <action>refresh:WIFI_KEY_TYPE</action> 2.390 + </tree> 2.391 + <hbox> 2.392 + <text width-chars=\"50\"> 2.393 + <label> 2.394 +\"Please double clic on a network to modify or remove it\" 2.395 + </label> 2.396 + </text> 2.397 + <button> 2.398 + <label>Add Network</label> 2.399 + <input file icon=\"gtk-add\"></input> 2.400 + <action>$0 add_favorite_network_box</action> 2.401 + <action>refresh:FAVORITE</action> 2.402 + </button> 2.403 + </hbox> 2.404 + </vbox>" 2.405 + 2.406 + # Configuration tab 2.407 + WIFI_DIALOG=${WIFI_DIALOG}' 2.408 + <vbox> 2.409 + <frame Base> 2.410 + <hbox> 2.411 + <text use-markup="true"> 2.412 + <label>"<b>Interface:</b>"</label> 2.413 + </text> 2.414 + <entry> 2.415 + <input>. /etc/network.conf; echo "$WIFI_INTERFACE"</input> 2.416 + <variable>WIFI_INTERFACE</variable> 2.417 + </entry> 2.418 + </hbox> 2.419 + <hbox> 2.420 + <text use-markup="true"> 2.421 + <label>"<b>ESSID: </b>"</label> 2.422 + </text> 2.423 + <entry> 2.424 + <input>. /etc/network.conf; echo "$WIFI_ESSID"</input> 2.425 + <variable>WIFI_ESSID</variable> 2.426 + </entry> 2.427 + </hbox> 2.428 + <hbox> 2.429 + <text use-markup="true"> 2.430 + <label>"<b>Key: </b>"</label> 2.431 + </text> 2.432 + <entry> 2.433 + <input>. /etc/network.conf; echo "$WIFI_KEY"</input> 2.434 + <variable>WIFI_KEY</variable> 2.435 + </entry> 2.436 + <combobox>' 2.437 + tmp2="${WIFI_DIALOG}<item>$WIFI_KEY_TYPE</item>" 2.438 + for i in none WEP WPA any; do 2.439 + [ "$i" = "$WIFI_KEY_TYPE" ] || tmp2="$tmp2<item>$i</item>" 2.440 + done 2.441 + tmp3=' <variable>WIFI_KEY_TYPE</variable> 2.442 + </combobox> 2.443 + </hbox> 2.444 + </frame> 2.445 + <frame Advanced> 2.446 + <hbox> 2.447 + <text use-markup="true"> 2.448 + <label>"<b>Channel/Mode:</b>"</label> 2.449 + </text> 2.450 + <entry> 2.451 + <input>. /etc/network.conf; echo "$WIFI_CHANNEL"</input> 2.452 + <variable>WIFI_CHANNEL</variable> 2.453 + </entry> 2.454 + 2.455 + <combobox> 2.456 + <variable>WIFI_MODE</variable>' 2.457 + tmp2="$tmp2$tmp3<item>$WIFI_MODE</item>" 2.458 + for i in managed ad-hoc master repeater secondary monitor; do 2.459 + [ "$i" = "$WIFI_MODE" ] || tmp2="$tmp2<item>$i</item>" 2.460 + done 2.461 + tmp3=' </combobox> 2.462 + </hbox> 2.463 + <hbox> 2.464 + <text use-markup="true"> 2.465 + <label>"<b>Iwconfig args:</b>"</label> 2.466 + </text> 2.467 + <entry> 2.468 + <input>. /etc/network.conf; echo "$WIFI_IWCONFIG_ARGS"</input> 2.469 + <variable>WIFI_IWCONFIG_ARGS</variable> 2.470 + </entry>' 2.471 + WIFI_DIALOG="$tmp$tmp2$tmp3 2.472 + $(helpbutton iwconfig 80x24) 2.473 + $(manbutton 8 iwconfig) 2.474 + </hbox> 2.475 + </frame>" 2.476 + 2.477 + # Start Button for manual configuration. 2.478 + WIFI_DIALOG=${WIFI_DIALOG}' 2.479 + <hbox> 2.480 + <button> 2.481 + <label>Start connection</label> 2.482 + <input file icon="forward"></input> 2.483 + <action>[ "$WIFI_KEY_TYPE" = "WPA" -a ! -x /usr/bin/wpa_supplicant ] && xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title "wpa_supplicant install" -e "tazpkg get-install wpa_supplicant ; echo -e \"----\n\nENTER to continue...\" && read close"</action> 2.484 + <action>sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/ /etc/network.conf</action> 2.485 + <action>sed -i s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/ /etc/network.conf</action> 2.486 + <action>sed -i s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/ /etc/network.conf</action> 2.487 + <action>sed -i s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/ /etc/network.conf</action> 2.488 + <action>sed -i s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/ /etc/network.conf</action> 2.489 + <action>sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" /etc/network.conf</action> 2.490 + <action>sed -i s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/ /etc/network.conf</action> 2.491 + <action>sed -i s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/ /etc/network.conf</action> 2.492 + <action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action> 2.493 + <action>ifconfig $WIFI_INTERFACE down</action> 2.494 + <action>iwconfig $WIFI_INTERFACE txpower auto</action> 2.495 + <action>/etc/init.d/network.sh restart</action> 2.496 + <action>refresh:ESSID_LIST</action> 2.497 + <action>refresh:WIFI_ESSID</action> 2.498 + <action>refresh:WIFI_KEY</action> 2.499 + <action>refresh:WIFI_KEY_TYPE</action> 2.500 + </button> 2.501 + </hbox> 2.502 + </vbox>' 2.503 + 2.504 + # Kernel Modules, firmware and tazndisbox note + button. 2.505 + WIFI_DIALOG=${WIFI_DIALOG}" 2.506 + <vbox> 2.507 + <hbox> 2.508 + <text width-chars=\"64\"> 2.509 + <label> 2.510 +\" 2.511 +Some Wireless Adapters need non-free firmware, please install them 2.512 +before loading the corresponding module. Note: you can use Tazhw 2.513 +to automaticaly detect your PCI, PCMCIA or USB Wireless adapter. 2.514 +\" 2.515 + </label> 2.516 + </text> 2.517 + </hbox> 2.518 + <hbox> 2.519 + <text use-markup=\"true\"> 2.520 + <label>\"<b>Tools:</b>\"</label> 2.521 + </text> 2.522 + <button> 2.523 + <input file icon=\"computer\"></input> 2.524 + <label>Auto detect devices</label> 2.525 + <action>tazhw box</action> 2.526 + <action>refresh:ESSID_LIST</action> 2.527 + </button>" 2.528 + # Display firmware stuff, tazndisbox button if installed and close 2.529 + # tab + notebook 2.530 + if [ -x /usr/bin/tazndisbox ]; then 2.531 + WIFI_DIALOG=${WIFI_DIALOG}" 2.532 + <button> 2.533 + <input file icon=\"system-installer\"></input> 2.534 + <label>Install Windows driver</label> 2.535 + <action>tazndisbox</action> 2.536 + <action>refresh:ESSID_LIST</action> 2.537 + </button>" 2.538 + fi 2.539 + WIFI_DIALOG=${WIFI_DIALOG}" 2.540 + </hbox> 2.541 + <hbox> 2.542 + <text use-markup=\"true\"> 2.543 + <label>\"<b>Module:</b>\"</label> 2.544 + </text> 2.545 + <combobox> 2.546 + <variable>MODULE</variable>" 2.547 + WIFI_DIALOG="${WIFI_DIALOG}$(find /lib/modules/$(uname -r)/kernel/drivers/net/wireless -type f 2> /dev/null | sed 's,/.*/\(.*\).ko.*,<item>\1</item>,')" 2.548 + WIFI_DIALOG=${WIFI_DIALOG}' 2.549 + </combobox> 2.550 + <button> 2.551 + <label>Load</label> 2.552 + <input file icon="forward"></input> 2.553 + <action>modprobe $MODULE</action> 2.554 + </button> 2.555 + <button> 2.556 + <label>Unload</label> 2.557 + <input file icon="undo"></input> 2.558 + <action>modprobe -r $MODULE</action> 2.559 + </button> 2.560 + <button> 2.561 + <label>Lsmod</label> 2.562 + <input file icon="computer"></input> 2.563 + <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title "Modules (q to quit)" -e "lsmod | less"</action> 2.564 + </button> 2.565 + </hbox>' 2.566 + # Firmware stuff. 2.567 + tmp=$(for i in /usr/bin/get*firmware; do 2.568 + [ -x $i ] || continue 2.569 + [ "$i" = "/usr/bin/get-wifi-firmware" ] && continue 2.570 + [ -d /var/lib/tazpkg/installed/${i#/usr/bin/get-} ] && continue 2.571 + echo "<item>${i#/usr/bin/get-}</item>"; done) 2.572 + [ -n "$tmp" ] && tmp=" 2.573 + <hbox> 2.574 + <text use-markup=\"true\"> 2.575 + <label>\"<b>Firmware:</b>\"</label> 2.576 + </text> 2.577 + <combobox><variable>FIRMWARE</variable>$tmp</combobox> 2.578 + <button> 2.579 + <label>Install</label> 2.580 + <input file icon=\"go-jump\"></input> 2.581 + <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title \"Install \$FIRMWARE\" -e \"get-\$FIRMWARE\"</action> 2.582 + <action>refresh:ESSID_LIST</action> 2.583 + </button> 2.584 + <button> 2.585 + <input file icon=\"system-file-manager\"></input> 2.586 + <label>List files</label> 2.587 + <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 100x25 -title \"Firmware files (q to quit)\" -e \"find /lib/firmware -exec ls -ld {} \; | less\"</action> 2.588 + <action>refresh:ESSID_LIST</action> 2.589 + </button> 2.590 + </hbox>" 2.591 + 2.592 +# Bottom buttons 2.593 +export WIFI_DIALOG=${WIFI_DIALOG}${tmp}" 2.594 + </vbox> 2.595 + </notebook> 2.596 + <hbox> 2.597 + <button> 2.598 + <label>Stop connection</label> 2.599 + <input file icon=\"stop\"></input> 2.600 + <action>$0 stop_wifi_connexion</action> 2.601 + <action>refresh:ESSID_LIST</action> 2.602 + </button> 2.603 + <button> 2.604 + <label>Exit</label> 2.605 + <input file icon=\"exit\"></input> 2.606 + <action type=\"exit\">Exit</action> 2.607 + </button> 2.608 + </hbox> 2.609 + 2.610 +</vbox> 2.611 +</window>" 2.612 + gtkdialog --center --program=WIFI_DIALOG >/dev/null 2>&1 2.613 +} 2.614 + 2.615 +if [ -n "$1" ]; then 2.616 + $1 2.617 +else 2.618 + box 2.619 +fi 2.620 + 2.621 +exit 0