slitaz-tools rev 686

Move wifibox to old stuff
author Christophe Lincoln <pankso@slitaz.org>
date Wed Feb 29 02:11:49 2012 +0100 (2012-02-29)
parents e1a33cf5ed13
children c7faac72f654
files oldstuff/wifibox tazbox/tazbox tinyutils/wifibox
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/oldstuff/wifibox	Wed Feb 29 02:11:49 2012 +0100
     1.3 @@ -0,0 +1,686 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# GTKdialog interface to manage wireless connections in a simple way.
     1.7 +# Use tabs to indent, split commands from the GUI and use functions.
     1.8 +# Favorite networks are also supported
     1.9 +#
    1.10 +# (c) 2010 SliTaz GNU/Linux - GNU gpl v3
    1.11 +#
    1.12 +VERSION=20100118
    1.13 +
    1.14 +# Export script path and others if needed so we can use them in 'quote'.
    1.15 +export BIN=$0
    1.16 +export FAVORITES_WIFI=/etc/wireless
    1.17 +. /etc/network.conf
    1.18 +
    1.19 +# Wifibox is only for root.
    1.20 +if test $(id -u) != 0 ; then
    1.21 +	exec subox wifibox
    1.22 +	exit 0
    1.23 +fi
    1.24 +
    1.25 +# Sanity check
    1.26 +[ -x /usr/sbin/iwconfig ] || tazpkg get-install wireless_tools
    1.27 +[ -d $FAVORITES_WIFI ] || mkdir -p $FAVORITES_WIFI
    1.28 +rm -f $FAVORITES_WIFI/any.conf
    1.29 +
    1.30 +# Catch ESSIDs and format output for GTK tree. We get the list of
    1.31 +# networks by Cell and without spaces.
    1.32 +detect_wifi_networks()
    1.33 +{
    1.34 +	desktopbox notify "Scanning Wireless interface: $WIFI_INTERFACE" &
    1.35 +	if [ -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
    1.36 +		ifconfig $WIFI_INTERFACE up
    1.37 +		for i in `iwlist $WIFI_INTERFACE scan | sed s/"Cell "/Cell-/ | grep "Cell-" | awk '{print $1}'`
    1.38 +		do
    1.39 +			SCAN=`iwlist $WIFI_INTERFACE scan last | \
    1.40 +				awk '/(Cell|ESS|Qual|Encry|IE: WPA)/ {print}' | \
    1.41 +				sed s/"Cell "/Cell-/ | grep -A 5 "$i"`
    1.42 +			ESSID=`echo $SCAN | cut -d '"' -f 2`
    1.43 +			if echo "$SCAN" | grep -q Quality; then
    1.44 +				QUALITY=`echo $SCAN | sed 's/.*Quality=\([^ ]*\).*/\1/' | sed 's/.*Quality:\([^ ]*\).*/\1/'`
    1.45 +			else
    1.46 +				QUALITY="-"
    1.47 +			fi
    1.48 +			ENCRYPTION=`echo $SCAN | sed 's/.*key:\([^ ]*\).*/\1/'`
    1.49 +			# Check encryption type
    1.50 +			if echo "$SCAN" | grep -q WPA; then
    1.51 +				ENCRYPTION="${ENCRYPTION} (WPA)"
    1.52 +			fi
    1.53 +			# Connected or not connected...
    1.54 +			if ifconfig | grep -A 1 $WIFI_INTERFACE | \
    1.55 +				grep -q inet && iwconfig $WIFI_INTERFACE | \
    1.56 +				grep ESSID | grep -q -w "$ESSID"; then
    1.57 +				STATUS=connected
    1.58 +			else
    1.59 +				STATUS="-"
    1.60 +			fi
    1.61 +			echo -n ""
    1.62 +			echo "$ESSID | $QUALITY | $ENCRYPTION | $STATUS"
    1.63 +		done
    1.64 +	fi
    1.65 +}
    1.66 +
    1.67 +# cmdline functions
    1.68 +
    1.69 +# Toggle Software RF Switch on some laptops
    1.70 +set_rfswitch()
    1.71 +{
    1.72 +	for i in /proc/driver/acerhk/wirelessled /proc/acpi/asus/wled ; do
    1.73 +		[ -e $i ] && echo $1 > $i
    1.74 +	done
    1.75 +}
    1.76 +
    1.77 +# Configure /etc/network.conf and restart connection with init script.
    1.78 +start_wifi_connection()
    1.79 +{
    1.80 +	# Get tmp config created by connect_to_essid() if exists and set 
    1.81 +	# empty value to clean config file.
    1.82 +	if [ -f /tmp/wifi.conf ]; then
    1.83 +		. /tmp/wifi.conf
    1.84 +		WIFI_MODE=""
    1.85 +		WIFI_IWCONFIG_ARGS=""
    1.86 +		WIFI_CHANNEL=""
    1.87 +	fi
    1.88 +	sed -i "s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/" \
    1.89 +		/etc/network.conf
    1.90 +	sed -i "s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/" \
    1.91 +		/etc/network.conf
    1.92 +	sed -i "s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/" \
    1.93 +		/etc/network.conf
    1.94 +	sed -i "s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/" \
    1.95 +		/etc/network.conf
    1.96 +	sed -i "s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/" \
    1.97 +		/etc/network.conf
    1.98 +	sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" \
    1.99 +		/etc/network.conf
   1.100 +	sed -i "s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/" \
   1.101 +		/etc/network.conf
   1.102 +	sed -i "s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/" \
   1.103 +		/etc/network.conf	
   1.104 +	[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`
   1.105 +	ifconfig $WIFI_INTERFACE down
   1.106 +	set_rfswitch 1 
   1.107 +	iwconfig $WIFI_INTERFACE txpower auto
   1.108 +	/etc/init.d/network.sh restart
   1.109 +	# Remove tmp file (could be used to have wireless profiles)
   1.110 +	rm -f /tmp/wifi.conf
   1.111 +	sleep 2
   1.112 +}
   1.113 +
   1.114 +# We must sleep 4 sec to refresh networks list.
   1.115 +stop_wifi_connexion()
   1.116 +{
   1.117 +	sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"no\"/ \
   1.118 +		/etc/network.conf
   1.119 +	[ -x /etc/init.d/wpa_supplicant ] && /etc/init.d/wpa_supplicant stop
   1.120 +	ifconfig $WIFI_INTERFACE down
   1.121 +	iwconfig $WIFI_INTERFACE txpower off
   1.122 +	set_rfswitch 0 
   1.123 +	[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`
   1.124 +	sleep 2
   1.125 +}
   1.126 +
   1.127 +auto_connect_to_favorites_atboot()
   1.128 +{
   1.129 +	. $FAVORITES_WIFI/${FAVNET}.conf
   1.130 +	
   1.131 +	if grep -q "ssid=\"$FAVNET\"" /etc/wpa_supplicant.conf ; then
   1.132 +		# edit configuration
   1.133 +		sed -i "/start ${FAVNET}.conf/,/end ${FAVNET}.conf/s/[^_]ssid=.*/  ssid=\"$WIFI_ESSID\"/  " /etc/wpa_supplicant.conf
   1.134 +		sed -i "/start ${FAVNET}.conf/,/end ${FAVNET}.conf/s/psk=.*/psk=\"$WIFI_KEY\"/ " /etc/wpa_supplicant.conf
   1.135 +	else
   1.136 +		# add new configuration
   1.137 +		echo -e "
   1.138 +# start ${FAVNET}.conf configuration
   1.139 +network={ 
   1.140 +	ssid=\"$WIFI_ESSID\"
   1.141 +	scan_ssid=1 
   1.142 +	key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE 
   1.143 +	group=CCMP TKIP WEP104 WEP40 
   1.144 +	pairwise=CCMP TKIP 
   1.145 +	psk=\"$WIFI_KEY\" 
   1.146 +	priority=3  
   1.147 +} 
   1.148 +# end ${FAVNET}.conf configuration" >> /etc/wpa_supplicant.conf  
   1.149 +    fi
   1.150 +
   1.151 +}
   1.152 +
   1.153 +# Favorite wireless networks use only 3 values: essid. key and type of
   1.154 +# key
   1.155 +favorites_wifi_list()
   1.156 +{
   1.157 +	for i in $FAVORITES_WIFI/*.conf
   1.158 +	do
   1.159 +		WIFI_ESSID=""
   1.160 +		WIFI_KEY=""
   1.161 +		WIFI_KEY_TYPE=""
   1.162 +		. "$i"
   1.163 +		[ -z "$WIFI_ESSID" ] && WIFI_ESSID="Bad config file: $i"
   1.164 +		[ -z "$WIFI_KEY_TYPE" ] && WIFI_KEY_TYPE="-"
   1.165 +		if [ -n "$WIFI_KEY" ]; then
   1.166 +			WIFI_KEY="********"
   1.167 +		else
   1.168 +			WIFI_KEY="-"
   1.169 +		fi
   1.170 +		echo "$WIFI_ESSID | $WIFI_KEY_TYPE | $WIFI_KEY"
   1.171 +	done
   1.172 +}
   1.173 +
   1.174 +favorite_wifi_actions()
   1.175 +{
   1.176 +	cp -a $FAVORITES_WIFI/"$FAVORITE".conf /tmp/wifi.conf
   1.177 +	. /tmp/wifi.conf
   1.178 +	export CONNECT_FAVORITE="
   1.179 +<window title=\"Connect to: $WIFI_ESSID\" icon-name=\"network-wireless\">
   1.180 +<vbox>
   1.181 +	
   1.182 +	<text width-chars=\"54\">
   1.183 +		<label>
   1.184 +\"
   1.185 +ESSID name: $WIFI_ESSID
   1.186 +\"
   1.187 +		</label>
   1.188 +	</text>
   1.189 +	
   1.190 +	<hbox>
   1.191 +		<button>
   1.192 +			<label>Connect</label>
   1.193 +			<input file icon=\"forward\"></input>	
   1.194 +			<action>$0 start_wifi_connection</action>
   1.195 +			<action type=\"exit\">exit</action>
   1.196 +		</button>
   1.197 +		<button>
   1.198 +			<label>Edit settings</label>
   1.199 +			<input file icon=\"accessories-text-editor\"></input>	
   1.200 +			<action>leafpad $FAVORITES_WIFI/\"$FAVORITE\".conf</action>
   1.201 +			<action>rm -f /tmp/wifi.conf</action>					
   1.202 +		</button>
   1.203 +		<button>
   1.204 +			<label>Save Edits</label>
   1.205 +			<input file icon=\"document-save\"></input>	
   1.206 +			<action>export FAVNET=$WIFI_ESSID; $0 auto_connect_to_favorites_atboot</action>
   1.207 +			<action type=\"exit\">exit</action>					
   1.208 +		</button>
   1.209 +		<button>
   1.210 +			<label>Delete</label>
   1.211 +			<input file icon=\"gtk-delete\"></input>	
   1.212 +			<action>rm -f $FAVORITES_WIFI/\"$FAVORITE\".conf</action>
   1.213 +			<action>sed -i \"/start ${FAVORITE}.conf/,/end ${FAVORITE}.conf/d\" /etc/wpa_supplicant.conf</action>
   1.214 +			<action type=\"exit\">exit</action>
   1.215 +		</button>
   1.216 +		<button cancel></button>
   1.217 +	</hbox>
   1.218 +	
   1.219 +</vbox>
   1.220 +</window>"
   1.221 +	gtkdialog --center --program=CONNECT_FAVORITE >/dev/null
   1.222 +}
   1.223 +
   1.224 +add_favorite_network_box()
   1.225 +{
   1.226 +	ADD_FAVORITE='
   1.227 +<window title="Add new favorite Wireless" icon-name="network-wireless">
   1.228 +<vbox>
   1.229 +	<text width-chars="54">
   1.230 +		<label>
   1.231 +"
   1.232 +Please configure your new favorite Wireless network
   1.233 +"
   1.234 +		</label>
   1.235 +	</text>
   1.236 +	<hbox>
   1.237 +		<text use-markup="true">
   1.238 +			<label>"<b>ESSID:</b>"</label>
   1.239 +		</text>
   1.240 +		<entry>
   1.241 +			<variable>WIFI_ESSID</variable>
   1.242 +		</entry>
   1.243 +	</hbox>
   1.244 +	<hbox>
   1.245 +		<text use-markup="true">
   1.246 +			<label>"<b>Key:   </b>"</label>
   1.247 +		</text>
   1.248 +		<entry>
   1.249 +			<variable>WIFI_KEY</variable>
   1.250 +		</entry>
   1.251 +	</hbox>
   1.252 +	<hbox>
   1.253 +		<text use-markup="true">
   1.254 +			<label>"<b>Key type:</b>"</label>
   1.255 +		</text>
   1.256 +		<combobox>'
   1.257 +	tmp="${ADD_FAVORITE}<item>$WIFI_KEY_TYPE</item>"
   1.258 +	for i in none WEP WPA any; do
   1.259 +		tmp=${tmp}"<item>$i</item>"
   1.260 +	done
   1.261 +	export ADD_FAVORITE=${tmp}'
   1.262 +			<variable>WIFI_KEY_TYPE</variable>
   1.263 +		</combobox>
   1.264 +	</hbox>
   1.265 +	<hbox>
   1.266 +		<button>
   1.267 +			<label>Add to list</label>
   1.268 +			<input file icon="forward"></input>
   1.269 +			<action>echo "# Wireless connection configuration." > $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   1.270 +			<action>echo "#" >> /etc/wireless/"$WIFI_ESSID".conf</action>
   1.271 +			<action>echo "WIFI_ESSID=\"$WIFI_ESSID\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   1.272 +			<action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   1.273 +			<action>echo "WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   1.274 +			<action>export FAVNET=$WIFI_ESSID; $BIN auto_connect_to_favorites_atboot</action>
   1.275 +			<action type="exit">exit</action>
   1.276 +		</button>
   1.277 +		<button cancel></button>
   1.278 +	</hbox>
   1.279 +</vbox>
   1.280 +</window>'
   1.281 +	gtkdialog --center --program=ADD_FAVORITE #>/dev/null
   1.282 +}
   1.283 +
   1.284 +# GUI functions
   1.285 +
   1.286 +helpbutton()
   1.287 +{
   1.288 +	local label;
   1.289 +        label="<label>$3</label>"
   1.290 +	[ -n "$3" ] || label=""
   1.291 +	cat << EOT
   1.292 +<button>
   1.293 +	<input file icon="help"></input>$label
   1.294 +	<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>
   1.295 +</button>
   1.296 +EOT
   1.297 +}
   1.298 +
   1.299 +manbutton()
   1.300 +{
   1.301 +	cat << EOT
   1.302 +<button>
   1.303 +	<input file icon="browser"></input>
   1.304 +	<label>man</label>
   1.305 +	<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>
   1.306 +</button>
   1.307 +EOT
   1.308 +}
   1.309 +
   1.310 +# Independent dialog to connect to a wireless network. If encryption
   1.311 +# is on we ask for the security key.
   1.312 +connect_to_essid()
   1.313 +{
   1.314 +	SCAN=`iwlist $WIFI_INTERFACE scan | \
   1.315 +		awk '/(Cell|ESS|Qual|Encry|IE: WPA)/ {print}' | \
   1.316 +		grep -B 1 -A 1 "$ESSID_LIST"`
   1.317 +	WIFI_ESSID="$ESSID_LIST"
   1.318 +	ENCRYPTION=`echo $SCAN | sed 's/.*key:\([^ ]*\).*/\1/'`
   1.319 +	# Create tmp file used by active_wifi_connexion()
   1.320 +	cat > /tmp/wifi.conf << _EOF_
   1.321 +# Wireless connexion configuration file.
   1.322 +WIFI_ESSID="$ESSID_LIST"
   1.323 +_EOF_
   1.324 +	CONNECT_ESSID="
   1.325 +<window title=\"Connect to: $WIFI_ESSID\" icon-name=\"network-wireless\">
   1.326 +<vbox>
   1.327 +	<text width-chars=\"54\">
   1.328 +		<label>
   1.329 +\"
   1.330 +Connect $WIFI_INTERFACE to: $WIFI_ESSID
   1.331 +\"
   1.332 +		</label>
   1.333 +	</text>"
   1.334 +	# We maybe need a key to connect
   1.335 +	if [ "$ENCRYPTION" = "on" ] && [ "$ESSID_LIST" != "any" ]; then
   1.336 +		# WPA
   1.337 +		if echo "$SCAN" | grep -q WPA; then
   1.338 +			echo 'WIFI_KEY_TYPE="WPA"' >> /tmp/wifi.conf
   1.339 +			CONNECT_ESSID=${CONNECT_ESSID}'
   1.340 +			<hbox>
   1.341 +				<text use-markup="true">
   1.342 +					<label>"<b>WPA Key:</b>"</label>
   1.343 +				</text>
   1.344 +				<entry>
   1.345 +					<input>. /etc/network.conf; echo "$WIFI_KEY"</input>
   1.346 +					<variable>WIFI_KEY</variable>
   1.347 +				</entry>
   1.348 +			</hbox>'
   1.349 +		else
   1.350 +			# WEP
   1.351 +			echo 'WIFI_KEY_TYPE="WEP"' >> /tmp/wifi.conf
   1.352 +			CONNECT_ESSID=${CONNECT_ESSID}'
   1.353 +			<hbox>
   1.354 +				<text use-markup="true">
   1.355 +					<label>"<b>WEP Key:</b>"</label>
   1.356 +				</text>
   1.357 +				<entry>
   1.358 +					<input>. /etc/network.conf; echo "$WIFI_KEY"</input>
   1.359 +					<variable>WIFI_KEY</variable>
   1.360 +				</entry>
   1.361 +			</hbox>'
   1.362 +		fi
   1.363 +	else
   1.364 +		# No encryption
   1.365 +		echo 'WIFI_KEY=""' >> /tmp/wifi.conf
   1.366 +		echo 'WIFI_KEY_TYPE=""' >> /tmp/wifi.conf
   1.367 +		start_wifi_connection
   1.368 +		exit 0
   1.369 +	fi
   1.370 +	# Add key to config file so active_wifi_connexion() can use it.
   1.371 +	# WIFI_KEY is not exported if we quote with --> "
   1.372 +	export CONNECT_ESSID=${CONNECT_ESSID}'
   1.373 +	<hbox>
   1.374 +		<button>
   1.375 +			<label>Connect</label>
   1.376 +			<input file icon="forward"></input>	
   1.377 +			<action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> /tmp/wifi.conf</action>
   1.378 +			<action>$BIN start_wifi_connection</action>
   1.379 +			<action type="exit">exit</action>
   1.380 +		</button>
   1.381 +		<button cancel></button>
   1.382 +	</hbox>
   1.383 +</vbox>
   1.384 +</window>'
   1.385 +	gtkdialog --center --program=CONNECT_ESSID #>/dev/null
   1.386 +}
   1.387 +
   1.388 +# Wifibox start with Networks tab.
   1.389 +box()
   1.390 +{
   1.391 +	WIFI_DIALOG="
   1.392 +<window title=\"Wireless manager\" icon-name=\"network-wireless\">
   1.393 +<vbox>
   1.394 +	
   1.395 +	<notebook labels=\"Networks|Favorites|Configuration|Drivers\">
   1.396 +	
   1.397 +	<vbox>
   1.398 +		<tree icon=\"network-wireless\">
   1.399 +			<width>520</width><height>160</height>
   1.400 +			<variable>ESSID_LIST</variable>
   1.401 +			<label>ESSID|Quality|Encryption|Status</label>
   1.402 +			<input>$0 detect_wifi_networks</input>
   1.403 +			<item icon=\"network-wireless\">any | * | off | (auto-connect)</item>
   1.404 +			<action>$0 connect_to_essid</action>
   1.405 +			<action>refresh:ESSID_LIST</action>
   1.406 +			<action>refresh:WIFI_ESSID</action>
   1.407 +			<action>refresh:WIFI_KEY</action>
   1.408 +			<action>refresh:WIFI_KEY_TYPE</action>
   1.409 +		</tree>
   1.410 +		<hbox>
   1.411 +			<text width-chars=\"54\">
   1.412 +				<label>
   1.413 +\"Please double click on a network to connect or enter security key\"
   1.414 +				</label>
   1.415 +			</text>
   1.416 +			<button>
   1.417 +				<label>Refresh list</label>
   1.418 +				<input file icon=\"reload\"></input>
   1.419 +				<action>refresh:ESSID_LIST</action>
   1.420 +			</button>
   1.421 +		</hbox>
   1.422 +	</vbox>"
   1.423 +	
   1.424 +	
   1.425 +	# Favorite networks
   1.426 +	WIFI_DIALOG=${WIFI_DIALOG}"	
   1.427 +	<vbox>
   1.428 +	    <tree icon=\"network-wireless\">
   1.429 +			<width>500</width><height>160</height>
   1.430 +			<variable>FAVORITE</variable>
   1.431 +			<label>ESSID|Key Type|Key status</label>
   1.432 +			<input>$0 favorites_wifi_list</input>
   1.433 +			<item icon=\"network-wireless\">any | - | -</item>
   1.434 +			<action>$0 favorite_wifi_actions</action>
   1.435 +			<action>refresh:FAVORITE</action>
   1.436 +			<action>refresh:ESSID_LIST</action>
   1.437 +			<action>refresh:WIFI_ESSID</action>
   1.438 +			<action>refresh:WIFI_KEY</action>
   1.439 +			<action>refresh:WIFI_KEY_TYPE</action>
   1.440 +		</tree>
   1.441 +		<hbox>
   1.442 +			<text width-chars=\"65\">
   1.443 +				<label>
   1.444 +\"Favorite networks connect automatically when the computer is started           \"
   1.445 +				</label>
   1.446 +			</text>
   1.447 +		</hbox>
   1.448 +		<hbox>
   1.449 +			<text width-chars=\"50\">
   1.450 +				<label>
   1.451 +\"Please double click on a network to modify or remove it\"
   1.452 +				</label>
   1.453 +			</text>
   1.454 +			<button>
   1.455 +				<label>Add Network</label>
   1.456 +				<input file icon=\"gtk-add\"></input>
   1.457 +				<action>$0 add_favorite_network_box</action>
   1.458 +				<action>refresh:FAVORITE</action>
   1.459 +			</button>
   1.460 +		</hbox>
   1.461 +	</vbox>"
   1.462 +
   1.463 +	# Configuration tab
   1.464 +	WIFI_DIALOG=${WIFI_DIALOG}'
   1.465 +	<vbox>
   1.466 +		<frame Basic>
   1.467 +			<hbox>
   1.468 +				<text use-markup="true">
   1.469 +					<label>"<b>Interface:</b>"</label>
   1.470 +				</text>
   1.471 +				<entry>
   1.472 +					<input>. /etc/network.conf; echo "$WIFI_INTERFACE"</input>
   1.473 +					<variable>WIFI_INTERFACE</variable>
   1.474 +				</entry>
   1.475 +			</hbox>
   1.476 +			<hbox>
   1.477 +				<text use-markup="true">
   1.478 +					<label>"<b>ESSID:        </b>"</label>
   1.479 +				</text>
   1.480 +				<entry>
   1.481 +					<input>. /etc/network.conf; echo "$WIFI_ESSID"</input>
   1.482 +					<variable>WIFI_ESSID</variable>
   1.483 +				</entry>
   1.484 +			</hbox>
   1.485 +			<hbox>
   1.486 +				<text use-markup="true">
   1.487 +					<label>"<b>Key:           </b>"</label>
   1.488 +				</text>
   1.489 +				<entry>
   1.490 +					<input>. /etc/network.conf; echo "$WIFI_KEY"</input>
   1.491 +					<variable>WIFI_KEY</variable>
   1.492 +				</entry>
   1.493 +				<combobox>'
   1.494 +	tmp2="${WIFI_DIALOG}<item>$WIFI_KEY_TYPE</item>"
   1.495 +	for i in none WEP WPA any; do
   1.496 +		[ "$i" = "$WIFI_KEY_TYPE" ] || tmp2="$tmp2<item>$i</item>"
   1.497 +	done
   1.498 +	tmp3='		<variable>WIFI_KEY_TYPE</variable>
   1.499 +				</combobox>
   1.500 +			</hbox>
   1.501 +		</frame>
   1.502 +		<frame Advanced>
   1.503 +			<hbox>
   1.504 +				<text use-markup="true">
   1.505 +					<label>"<b>Channel/Mode:</b>"</label>
   1.506 +				</text>
   1.507 +				<entry>
   1.508 +					<input>. /etc/network.conf; echo "$WIFI_CHANNEL"</input>
   1.509 +					<variable>WIFI_CHANNEL</variable>
   1.510 +				</entry>
   1.511 +				
   1.512 +				<combobox>
   1.513 +					<variable>WIFI_MODE</variable>'
   1.514 +	tmp2="$tmp2$tmp3<item>$WIFI_MODE</item>"
   1.515 +	for i in managed ad-hoc master repeater secondary monitor; do
   1.516 +		[ "$i" = "$WIFI_MODE" ] || tmp2="$tmp2<item>$i</item>"
   1.517 +	done
   1.518 +	tmp3='		</combobox>
   1.519 +			</hbox>
   1.520 +			<hbox>
   1.521 +				<text use-markup="true">
   1.522 +					<label>"<b>Iwconfig args:</b> "</label>
   1.523 +				</text>
   1.524 +				<entry>
   1.525 +					<input>. /etc/network.conf; echo "$WIFI_IWCONFIG_ARGS"</input>
   1.526 +					<variable>WIFI_IWCONFIG_ARGS</variable>
   1.527 +				</entry>'
   1.528 +	WIFI_DIALOG="$tmp$tmp2$tmp3
   1.529 +	$(helpbutton iwconfig 80x24)
   1.530 +	$(manbutton 8 iwconfig)
   1.531 +			</hbox>
   1.532 +		</frame>"
   1.533 +		
   1.534 +	# Start Button for manual configuration.
   1.535 +	WIFI_DIALOG=${WIFI_DIALOG}'
   1.536 +		<hbox>
   1.537 +		   <button>
   1.538 +				<label>Save to Favorites</label>
   1.539 +				<input file icon="document-save"></input>
   1.540 +				<action>echo "# Wireless connection configuration." > $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   1.541 +				<action>echo "#" >> /etc/wireless/"$WIFI_ESSID".conf</action>
   1.542 +				<action>echo "WIFI_ESSID=\"$WIFI_ESSID\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   1.543 +				<action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   1.544 +				<action>echo "WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   1.545 +				<action>export FAVNET=$WIFI_ESSID; $BIN auto_connect_to_favorites_atboot</action>	
   1.546 +				<action>refresh:FAVORITE</action>
   1.547 +			</button>
   1.548 +			<button>
   1.549 +				<label>Start connection</label>
   1.550 +				<input file icon="forward"></input>
   1.551 +				<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>
   1.552 +				<action>sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/ /etc/network.conf</action>
   1.553 +				<action>sed -i s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/ /etc/network.conf</action>
   1.554 +				<action>sed -i s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/ /etc/network.conf</action>
   1.555 +				<action>sed -i s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/ /etc/network.conf</action>
   1.556 +				<action>sed -i s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/ /etc/network.conf</action>
   1.557 +				<action>sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" /etc/network.conf</action>
   1.558 +				<action>sed -i s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/ /etc/network.conf</action>
   1.559 +				<action>sed -i s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/ /etc/network.conf</action>
   1.560 +				<action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action>
   1.561 +				<action>ifconfig $WIFI_INTERFACE down</action>
   1.562 +				<action>iwconfig $WIFI_INTERFACE txpower auto</action>
   1.563 +				<action>/etc/init.d/network.sh restart</action>
   1.564 +				<action>refresh:ESSID_LIST</action>
   1.565 +				<action>refresh:WIFI_ESSID</action>
   1.566 +				<action>refresh:WIFI_KEY</action>
   1.567 +				<action>refresh:WIFI_KEY_TYPE</action>
   1.568 +			</button>
   1.569 +		</hbox>
   1.570 +	</vbox>'
   1.571 +
   1.572 +	# Kernel Modules, firmware and tazndisbox note + button.
   1.573 +	WIFI_DIALOG=${WIFI_DIALOG}"
   1.574 +	<vbox>
   1.575 +		<hbox>
   1.576 +			<text width-chars=\"64\">
   1.577 +				<label>
   1.578 +\"
   1.579 +Some Wireless Adapters need non-free firmware. Please install the
   1.580 +firmware before loading the corresponding module. Note that you can use 
   1.581 +Tazhw to automatically detect your PCI, PCMCIA or USB Wireless adapter.
   1.582 +\"
   1.583 +				</label>
   1.584 +			</text>
   1.585 +		</hbox>
   1.586 +		<hbox>
   1.587 +			<text use-markup=\"true\">
   1.588 +				<label>\"<b>Tools:</b>\"</label>
   1.589 +			</text>
   1.590 +			<button>
   1.591 +				<input file icon=\"computer\"></input>
   1.592 +				<label>Auto detect devices</label>
   1.593 +				<action>tazhw box</action>
   1.594 +				<action>refresh:ESSID_LIST</action>
   1.595 +			</button>"
   1.596 +			# Display firmware stuff, tazndisbox button if installed and close 
   1.597 +			# tab + notebook
   1.598 +			if [ -x /usr/bin/tazndisbox ]; then
   1.599 +				WIFI_DIALOG=${WIFI_DIALOG}"
   1.600 +			<button>
   1.601 +				<input file icon=\"system-installer\"></input>
   1.602 +				<label>Install Windows driver</label>
   1.603 +				<action>tazndisbox</action>
   1.604 +				<action>refresh:ESSID_LIST</action>
   1.605 +			</button>"
   1.606 +			fi
   1.607 +		WIFI_DIALOG=${WIFI_DIALOG}"
   1.608 +		</hbox>
   1.609 +		<hbox>
   1.610 +			<text use-markup=\"true\">
   1.611 +				<label>\"<b>Module:</b>\"</label>
   1.612 +			</text>
   1.613 +			<combobox>
   1.614 +				<variable>MODULE</variable>"
   1.615 +	WIFI_DIALOG="${WIFI_DIALOG}$(find /lib/modules/$(uname -r)/kernel/drivers/net/wireless -type f 2> /dev/null |  sed 's,/.*/\(.*\).ko.*,<item>\1</item>,')"
   1.616 +	WIFI_DIALOG=${WIFI_DIALOG}'
   1.617 +			</combobox>
   1.618 +			<button>
   1.619 +				<label>Load</label>
   1.620 +				<input file icon="forward"></input>
   1.621 +				<action>modprobe $MODULE</action>
   1.622 +			</button>
   1.623 +			<button>
   1.624 +				<label>Unload</label>
   1.625 +				<input file icon="undo"></input>
   1.626 +				<action>modprobe -r $MODULE</action>
   1.627 +			</button>
   1.628 +			<button>
   1.629 +				<label>Lsmod</label>
   1.630 +				<input file icon="computer"></input>
   1.631 +				<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title "Modules (q to quit)" -e "lsmod | less"</action>
   1.632 +			</button>
   1.633 +		</hbox>'
   1.634 +	# Firmware stuff.
   1.635 +	tmp=$(for i in /usr/bin/get*firmware; do
   1.636 +		[ -x $i ] || continue
   1.637 +		[ "$i" = "/usr/bin/get-wifi-firmware" ] && continue
   1.638 +		[ -d /var/lib/tazpkg/installed/${i#/usr/bin/get-} ] && continue
   1.639 +		echo "<item>${i#/usr/bin/get-}</item>"; done)
   1.640 +		[ -n "$tmp" ] && tmp="
   1.641 +		<hbox>
   1.642 +			<text use-markup=\"true\">
   1.643 +				<label>\"<b>Firmware:</b>\"</label>
   1.644 +			</text>
   1.645 +			<combobox><variable>FIRMWARE</variable>$tmp</combobox>
   1.646 +			<button>
   1.647 +				<label>Install</label>
   1.648 +				<input file icon=\"go-jump\"></input>
   1.649 +				<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title \"Install \$FIRMWARE\" -e \"get-\$FIRMWARE\"</action>
   1.650 +				<action>refresh:ESSID_LIST</action>
   1.651 +			</button>
   1.652 +			<button>
   1.653 +				<input file icon=\"system-file-manager\"></input>
   1.654 +				<label>List files</label>
   1.655 +				<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>
   1.656 +				<action>refresh:ESSID_LIST</action>
   1.657 +			</button>
   1.658 +		</hbox>"
   1.659 +
   1.660 +# Bottom buttons
   1.661 +export WIFI_DIALOG=${WIFI_DIALOG}${tmp}"
   1.662 +		</vbox>
   1.663 +	</notebook>
   1.664 +	<hbox>
   1.665 +		<button>
   1.666 +			<label>Stop connection</label>
   1.667 +			<input file icon=\"stop\"></input>
   1.668 +			<action>$0 stop_wifi_connexion</action>
   1.669 +			<action>refresh:ESSID_LIST</action>
   1.670 +		</button>
   1.671 +		<button>
   1.672 +			<label>Exit</label>
   1.673 +			<input file icon=\"exit\"></input>
   1.674 +			<action type=\"exit\">Exit</action>
   1.675 +		</button>
   1.676 +	</hbox>
   1.677 +	
   1.678 +</vbox>
   1.679 +</window>"
   1.680 +	gtkdialog --center --program=WIFI_DIALOG #>/dev/null 2>&1
   1.681 +}
   1.682 +
   1.683 +if [ -n "$1" ]; then
   1.684 +	$1
   1.685 +else
   1.686 +	box
   1.687 +fi
   1.688 +
   1.689 +exit 0
     2.1 --- a/tazbox/tazbox	Mon Feb 27 23:33:37 2012 +0100
     2.2 +++ b/tazbox/tazbox	Wed Feb 29 02:11:49 2012 +0100
     2.3 @@ -55,7 +55,7 @@
     2.4  	text=$(gettext "Slitaz admin password")
     2.5  	note=$(gettext "Please enter root password (default root) to execute:")
     2.6  	yad --title="Slitaz - su" --window-icon=$icon \
     2.7 -		--width=520 --height=160 \
     2.8 +		--width=520 --height=140 \
     2.9  		--text="<b>$text</b>\n$note\n$SU_CMD\n" \
    2.10  		--image="slitaz-menu" --image-on-top \
    2.11  		--center --on-top --form $PASSWD \
     3.1 --- a/tinyutils/wifibox	Mon Feb 27 23:33:37 2012 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,686 +0,0 @@
     3.4 -#!/bin/sh
     3.5 -#
     3.6 -# GTKdialog interface to manage wireless connections in a simple way.
     3.7 -# Use tabs to indent, split commands from the GUI and use functions.
     3.8 -# Favorite networks are also supported
     3.9 -#
    3.10 -# (c) 2010 SliTaz GNU/Linux - GNU gpl v3
    3.11 -#
    3.12 -VERSION=20100118
    3.13 -
    3.14 -# Export script path and others if needed so we can use them in 'quote'.
    3.15 -export BIN=$0
    3.16 -export FAVORITES_WIFI=/etc/wireless
    3.17 -. /etc/network.conf
    3.18 -
    3.19 -# Wifibox is only for root.
    3.20 -if test $(id -u) != 0 ; then
    3.21 -	exec subox wifibox
    3.22 -	exit 0
    3.23 -fi
    3.24 -
    3.25 -# Sanity check
    3.26 -[ -x /usr/sbin/iwconfig ] || tazpkg get-install wireless_tools
    3.27 -[ -d $FAVORITES_WIFI ] || mkdir -p $FAVORITES_WIFI
    3.28 -rm -f $FAVORITES_WIFI/any.conf
    3.29 -
    3.30 -# Catch ESSIDs and format output for GTK tree. We get the list of
    3.31 -# networks by Cell and without spaces.
    3.32 -detect_wifi_networks()
    3.33 -{
    3.34 -	desktopbox notify "Scanning Wireless interface: $WIFI_INTERFACE" &
    3.35 -	if [ -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
    3.36 -		ifconfig $WIFI_INTERFACE up
    3.37 -		for i in `iwlist $WIFI_INTERFACE scan | sed s/"Cell "/Cell-/ | grep "Cell-" | awk '{print $1}'`
    3.38 -		do
    3.39 -			SCAN=`iwlist $WIFI_INTERFACE scan last | \
    3.40 -				awk '/(Cell|ESS|Qual|Encry|IE: WPA)/ {print}' | \
    3.41 -				sed s/"Cell "/Cell-/ | grep -A 5 "$i"`
    3.42 -			ESSID=`echo $SCAN | cut -d '"' -f 2`
    3.43 -			if echo "$SCAN" | grep -q Quality; then
    3.44 -				QUALITY=`echo $SCAN | sed 's/.*Quality=\([^ ]*\).*/\1/' | sed 's/.*Quality:\([^ ]*\).*/\1/'`
    3.45 -			else
    3.46 -				QUALITY="-"
    3.47 -			fi
    3.48 -			ENCRYPTION=`echo $SCAN | sed 's/.*key:\([^ ]*\).*/\1/'`
    3.49 -			# Check encryption type
    3.50 -			if echo "$SCAN" | grep -q WPA; then
    3.51 -				ENCRYPTION="${ENCRYPTION} (WPA)"
    3.52 -			fi
    3.53 -			# Connected or not connected...
    3.54 -			if ifconfig | grep -A 1 $WIFI_INTERFACE | \
    3.55 -				grep -q inet && iwconfig $WIFI_INTERFACE | \
    3.56 -				grep ESSID | grep -q -w "$ESSID"; then
    3.57 -				STATUS=connected
    3.58 -			else
    3.59 -				STATUS="-"
    3.60 -			fi
    3.61 -			echo -n ""
    3.62 -			echo "$ESSID | $QUALITY | $ENCRYPTION | $STATUS"
    3.63 -		done
    3.64 -	fi
    3.65 -}
    3.66 -
    3.67 -# cmdline functions
    3.68 -
    3.69 -# Toggle Software RF Switch on some laptops
    3.70 -set_rfswitch()
    3.71 -{
    3.72 -	for i in /proc/driver/acerhk/wirelessled /proc/acpi/asus/wled ; do
    3.73 -		[ -e $i ] && echo $1 > $i
    3.74 -	done
    3.75 -}
    3.76 -
    3.77 -# Configure /etc/network.conf and restart connection with init script.
    3.78 -start_wifi_connection()
    3.79 -{
    3.80 -	# Get tmp config created by connect_to_essid() if exists and set 
    3.81 -	# empty value to clean config file.
    3.82 -	if [ -f /tmp/wifi.conf ]; then
    3.83 -		. /tmp/wifi.conf
    3.84 -		WIFI_MODE=""
    3.85 -		WIFI_IWCONFIG_ARGS=""
    3.86 -		WIFI_CHANNEL=""
    3.87 -	fi
    3.88 -	sed -i "s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/" \
    3.89 -		/etc/network.conf
    3.90 -	sed -i "s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/" \
    3.91 -		/etc/network.conf
    3.92 -	sed -i "s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/" \
    3.93 -		/etc/network.conf
    3.94 -	sed -i "s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/" \
    3.95 -		/etc/network.conf
    3.96 -	sed -i "s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/" \
    3.97 -		/etc/network.conf
    3.98 -	sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" \
    3.99 -		/etc/network.conf
   3.100 -	sed -i "s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/" \
   3.101 -		/etc/network.conf
   3.102 -	sed -i "s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/" \
   3.103 -		/etc/network.conf	
   3.104 -	[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`
   3.105 -	ifconfig $WIFI_INTERFACE down
   3.106 -	set_rfswitch 1 
   3.107 -	iwconfig $WIFI_INTERFACE txpower auto
   3.108 -	/etc/init.d/network.sh restart
   3.109 -	# Remove tmp file (could be used to have wireless profiles)
   3.110 -	rm -f /tmp/wifi.conf
   3.111 -	sleep 2
   3.112 -}
   3.113 -
   3.114 -# We must sleep 4 sec to refresh networks list.
   3.115 -stop_wifi_connexion()
   3.116 -{
   3.117 -	sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"no\"/ \
   3.118 -		/etc/network.conf
   3.119 -	[ -x /etc/init.d/wpa_supplicant ] && /etc/init.d/wpa_supplicant stop
   3.120 -	ifconfig $WIFI_INTERFACE down
   3.121 -	iwconfig $WIFI_INTERFACE txpower off
   3.122 -	set_rfswitch 0 
   3.123 -	[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`
   3.124 -	sleep 2
   3.125 -}
   3.126 -
   3.127 -auto_connect_to_favorites_atboot()
   3.128 -{
   3.129 -	. $FAVORITES_WIFI/${FAVNET}.conf
   3.130 -	
   3.131 -	if grep -q "ssid=\"$FAVNET\"" /etc/wpa_supplicant.conf ; then
   3.132 -		# edit configuration
   3.133 -		sed -i "/start ${FAVNET}.conf/,/end ${FAVNET}.conf/s/[^_]ssid=.*/  ssid=\"$WIFI_ESSID\"/  " /etc/wpa_supplicant.conf
   3.134 -		sed -i "/start ${FAVNET}.conf/,/end ${FAVNET}.conf/s/psk=.*/psk=\"$WIFI_KEY\"/ " /etc/wpa_supplicant.conf
   3.135 -	else
   3.136 -		# add new configuration
   3.137 -		echo -e "
   3.138 -# start ${FAVNET}.conf configuration
   3.139 -network={ 
   3.140 -	ssid=\"$WIFI_ESSID\"
   3.141 -	scan_ssid=1 
   3.142 -	key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE 
   3.143 -	group=CCMP TKIP WEP104 WEP40 
   3.144 -	pairwise=CCMP TKIP 
   3.145 -	psk=\"$WIFI_KEY\" 
   3.146 -	priority=3  
   3.147 -} 
   3.148 -# end ${FAVNET}.conf configuration" >> /etc/wpa_supplicant.conf  
   3.149 -    fi
   3.150 -
   3.151 -}
   3.152 -
   3.153 -# Favorite wireless networks use only 3 values: essid. key and type of
   3.154 -# key
   3.155 -favorites_wifi_list()
   3.156 -{
   3.157 -	for i in $FAVORITES_WIFI/*.conf
   3.158 -	do
   3.159 -		WIFI_ESSID=""
   3.160 -		WIFI_KEY=""
   3.161 -		WIFI_KEY_TYPE=""
   3.162 -		. "$i"
   3.163 -		[ -z "$WIFI_ESSID" ] && WIFI_ESSID="Bad config file: $i"
   3.164 -		[ -z "$WIFI_KEY_TYPE" ] && WIFI_KEY_TYPE="-"
   3.165 -		if [ -n "$WIFI_KEY" ]; then
   3.166 -			WIFI_KEY="********"
   3.167 -		else
   3.168 -			WIFI_KEY="-"
   3.169 -		fi
   3.170 -		echo "$WIFI_ESSID | $WIFI_KEY_TYPE | $WIFI_KEY"
   3.171 -	done
   3.172 -}
   3.173 -
   3.174 -favorite_wifi_actions()
   3.175 -{
   3.176 -	cp -a $FAVORITES_WIFI/"$FAVORITE".conf /tmp/wifi.conf
   3.177 -	. /tmp/wifi.conf
   3.178 -	export CONNECT_FAVORITE="
   3.179 -<window title=\"Connect to: $WIFI_ESSID\" icon-name=\"network-wireless\">
   3.180 -<vbox>
   3.181 -	
   3.182 -	<text width-chars=\"54\">
   3.183 -		<label>
   3.184 -\"
   3.185 -ESSID name: $WIFI_ESSID
   3.186 -\"
   3.187 -		</label>
   3.188 -	</text>
   3.189 -	
   3.190 -	<hbox>
   3.191 -		<button>
   3.192 -			<label>Connect</label>
   3.193 -			<input file icon=\"forward\"></input>	
   3.194 -			<action>$0 start_wifi_connection</action>
   3.195 -			<action type=\"exit\">exit</action>
   3.196 -		</button>
   3.197 -		<button>
   3.198 -			<label>Edit settings</label>
   3.199 -			<input file icon=\"accessories-text-editor\"></input>	
   3.200 -			<action>leafpad $FAVORITES_WIFI/\"$FAVORITE\".conf</action>
   3.201 -			<action>rm -f /tmp/wifi.conf</action>					
   3.202 -		</button>
   3.203 -		<button>
   3.204 -			<label>Save Edits</label>
   3.205 -			<input file icon=\"document-save\"></input>	
   3.206 -			<action>export FAVNET=$WIFI_ESSID; $0 auto_connect_to_favorites_atboot</action>
   3.207 -			<action type=\"exit\">exit</action>					
   3.208 -		</button>
   3.209 -		<button>
   3.210 -			<label>Delete</label>
   3.211 -			<input file icon=\"gtk-delete\"></input>	
   3.212 -			<action>rm -f $FAVORITES_WIFI/\"$FAVORITE\".conf</action>
   3.213 -			<action>sed -i \"/start ${FAVORITE}.conf/,/end ${FAVORITE}.conf/d\" /etc/wpa_supplicant.conf</action>
   3.214 -			<action type=\"exit\">exit</action>
   3.215 -		</button>
   3.216 -		<button cancel></button>
   3.217 -	</hbox>
   3.218 -	
   3.219 -</vbox>
   3.220 -</window>"
   3.221 -	gtkdialog --center --program=CONNECT_FAVORITE >/dev/null
   3.222 -}
   3.223 -
   3.224 -add_favorite_network_box()
   3.225 -{
   3.226 -	ADD_FAVORITE='
   3.227 -<window title="Add new favorite Wireless" icon-name="network-wireless">
   3.228 -<vbox>
   3.229 -	<text width-chars="54">
   3.230 -		<label>
   3.231 -"
   3.232 -Please configure your new favorite Wireless network
   3.233 -"
   3.234 -		</label>
   3.235 -	</text>
   3.236 -	<hbox>
   3.237 -		<text use-markup="true">
   3.238 -			<label>"<b>ESSID:</b>"</label>
   3.239 -		</text>
   3.240 -		<entry>
   3.241 -			<variable>WIFI_ESSID</variable>
   3.242 -		</entry>
   3.243 -	</hbox>
   3.244 -	<hbox>
   3.245 -		<text use-markup="true">
   3.246 -			<label>"<b>Key:   </b>"</label>
   3.247 -		</text>
   3.248 -		<entry>
   3.249 -			<variable>WIFI_KEY</variable>
   3.250 -		</entry>
   3.251 -	</hbox>
   3.252 -	<hbox>
   3.253 -		<text use-markup="true">
   3.254 -			<label>"<b>Key type:</b>"</label>
   3.255 -		</text>
   3.256 -		<combobox>'
   3.257 -	tmp="${ADD_FAVORITE}<item>$WIFI_KEY_TYPE</item>"
   3.258 -	for i in none WEP WPA any; do
   3.259 -		tmp=${tmp}"<item>$i</item>"
   3.260 -	done
   3.261 -	export ADD_FAVORITE=${tmp}'
   3.262 -			<variable>WIFI_KEY_TYPE</variable>
   3.263 -		</combobox>
   3.264 -	</hbox>
   3.265 -	<hbox>
   3.266 -		<button>
   3.267 -			<label>Add to list</label>
   3.268 -			<input file icon="forward"></input>
   3.269 -			<action>echo "# Wireless connection configuration." > $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.270 -			<action>echo "#" >> /etc/wireless/"$WIFI_ESSID".conf</action>
   3.271 -			<action>echo "WIFI_ESSID=\"$WIFI_ESSID\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.272 -			<action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.273 -			<action>echo "WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.274 -			<action>export FAVNET=$WIFI_ESSID; $BIN auto_connect_to_favorites_atboot</action>
   3.275 -			<action type="exit">exit</action>
   3.276 -		</button>
   3.277 -		<button cancel></button>
   3.278 -	</hbox>
   3.279 -</vbox>
   3.280 -</window>'
   3.281 -	gtkdialog --center --program=ADD_FAVORITE #>/dev/null
   3.282 -}
   3.283 -
   3.284 -# GUI functions
   3.285 -
   3.286 -helpbutton()
   3.287 -{
   3.288 -	local label;
   3.289 -        label="<label>$3</label>"
   3.290 -	[ -n "$3" ] || label=""
   3.291 -	cat << EOT
   3.292 -<button>
   3.293 -	<input file icon="help"></input>$label
   3.294 -	<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>
   3.295 -</button>
   3.296 -EOT
   3.297 -}
   3.298 -
   3.299 -manbutton()
   3.300 -{
   3.301 -	cat << EOT
   3.302 -<button>
   3.303 -	<input file icon="browser"></input>
   3.304 -	<label>man</label>
   3.305 -	<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>
   3.306 -</button>
   3.307 -EOT
   3.308 -}
   3.309 -
   3.310 -# Independent dialog to connect to a wireless network. If encryption
   3.311 -# is on we ask for the security key.
   3.312 -connect_to_essid()
   3.313 -{
   3.314 -	SCAN=`iwlist $WIFI_INTERFACE scan | \
   3.315 -		awk '/(Cell|ESS|Qual|Encry|IE: WPA)/ {print}' | \
   3.316 -		grep -B 1 -A 1 "$ESSID_LIST"`
   3.317 -	WIFI_ESSID="$ESSID_LIST"
   3.318 -	ENCRYPTION=`echo $SCAN | sed 's/.*key:\([^ ]*\).*/\1/'`
   3.319 -	# Create tmp file used by active_wifi_connexion()
   3.320 -	cat > /tmp/wifi.conf << _EOF_
   3.321 -# Wireless connexion configuration file.
   3.322 -WIFI_ESSID="$ESSID_LIST"
   3.323 -_EOF_
   3.324 -	CONNECT_ESSID="
   3.325 -<window title=\"Connect to: $WIFI_ESSID\" icon-name=\"network-wireless\">
   3.326 -<vbox>
   3.327 -	<text width-chars=\"54\">
   3.328 -		<label>
   3.329 -\"
   3.330 -Connect $WIFI_INTERFACE to: $WIFI_ESSID
   3.331 -\"
   3.332 -		</label>
   3.333 -	</text>"
   3.334 -	# We maybe need a key to connect
   3.335 -	if [ "$ENCRYPTION" = "on" ] && [ "$ESSID_LIST" != "any" ]; then
   3.336 -		# WPA
   3.337 -		if echo "$SCAN" | grep -q WPA; then
   3.338 -			echo 'WIFI_KEY_TYPE="WPA"' >> /tmp/wifi.conf
   3.339 -			CONNECT_ESSID=${CONNECT_ESSID}'
   3.340 -			<hbox>
   3.341 -				<text use-markup="true">
   3.342 -					<label>"<b>WPA Key:</b>"</label>
   3.343 -				</text>
   3.344 -				<entry>
   3.345 -					<input>. /etc/network.conf; echo "$WIFI_KEY"</input>
   3.346 -					<variable>WIFI_KEY</variable>
   3.347 -				</entry>
   3.348 -			</hbox>'
   3.349 -		else
   3.350 -			# WEP
   3.351 -			echo 'WIFI_KEY_TYPE="WEP"' >> /tmp/wifi.conf
   3.352 -			CONNECT_ESSID=${CONNECT_ESSID}'
   3.353 -			<hbox>
   3.354 -				<text use-markup="true">
   3.355 -					<label>"<b>WEP Key:</b>"</label>
   3.356 -				</text>
   3.357 -				<entry>
   3.358 -					<input>. /etc/network.conf; echo "$WIFI_KEY"</input>
   3.359 -					<variable>WIFI_KEY</variable>
   3.360 -				</entry>
   3.361 -			</hbox>'
   3.362 -		fi
   3.363 -	else
   3.364 -		# No encryption
   3.365 -		echo 'WIFI_KEY=""' >> /tmp/wifi.conf
   3.366 -		echo 'WIFI_KEY_TYPE=""' >> /tmp/wifi.conf
   3.367 -		start_wifi_connection
   3.368 -		exit 0
   3.369 -	fi
   3.370 -	# Add key to config file so active_wifi_connexion() can use it.
   3.371 -	# WIFI_KEY is not exported if we quote with --> "
   3.372 -	export CONNECT_ESSID=${CONNECT_ESSID}'
   3.373 -	<hbox>
   3.374 -		<button>
   3.375 -			<label>Connect</label>
   3.376 -			<input file icon="forward"></input>	
   3.377 -			<action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> /tmp/wifi.conf</action>
   3.378 -			<action>$BIN start_wifi_connection</action>
   3.379 -			<action type="exit">exit</action>
   3.380 -		</button>
   3.381 -		<button cancel></button>
   3.382 -	</hbox>
   3.383 -</vbox>
   3.384 -</window>'
   3.385 -	gtkdialog --center --program=CONNECT_ESSID #>/dev/null
   3.386 -}
   3.387 -
   3.388 -# Wifibox start with Networks tab.
   3.389 -box()
   3.390 -{
   3.391 -	WIFI_DIALOG="
   3.392 -<window title=\"Wireless manager\" icon-name=\"network-wireless\">
   3.393 -<vbox>
   3.394 -	
   3.395 -	<notebook labels=\"Networks|Favorites|Configuration|Drivers\">
   3.396 -	
   3.397 -	<vbox>
   3.398 -		<tree icon=\"network-wireless\">
   3.399 -			<width>520</width><height>160</height>
   3.400 -			<variable>ESSID_LIST</variable>
   3.401 -			<label>ESSID|Quality|Encryption|Status</label>
   3.402 -			<input>$0 detect_wifi_networks</input>
   3.403 -			<item icon=\"network-wireless\">any | * | off | (auto-connect)</item>
   3.404 -			<action>$0 connect_to_essid</action>
   3.405 -			<action>refresh:ESSID_LIST</action>
   3.406 -			<action>refresh:WIFI_ESSID</action>
   3.407 -			<action>refresh:WIFI_KEY</action>
   3.408 -			<action>refresh:WIFI_KEY_TYPE</action>
   3.409 -		</tree>
   3.410 -		<hbox>
   3.411 -			<text width-chars=\"54\">
   3.412 -				<label>
   3.413 -\"Please double click on a network to connect or enter security key\"
   3.414 -				</label>
   3.415 -			</text>
   3.416 -			<button>
   3.417 -				<label>Refresh list</label>
   3.418 -				<input file icon=\"reload\"></input>
   3.419 -				<action>refresh:ESSID_LIST</action>
   3.420 -			</button>
   3.421 -		</hbox>
   3.422 -	</vbox>"
   3.423 -	
   3.424 -	
   3.425 -	# Favorite networks
   3.426 -	WIFI_DIALOG=${WIFI_DIALOG}"	
   3.427 -	<vbox>
   3.428 -	    <tree icon=\"network-wireless\">
   3.429 -			<width>500</width><height>160</height>
   3.430 -			<variable>FAVORITE</variable>
   3.431 -			<label>ESSID|Key Type|Key status</label>
   3.432 -			<input>$0 favorites_wifi_list</input>
   3.433 -			<item icon=\"network-wireless\">any | - | -</item>
   3.434 -			<action>$0 favorite_wifi_actions</action>
   3.435 -			<action>refresh:FAVORITE</action>
   3.436 -			<action>refresh:ESSID_LIST</action>
   3.437 -			<action>refresh:WIFI_ESSID</action>
   3.438 -			<action>refresh:WIFI_KEY</action>
   3.439 -			<action>refresh:WIFI_KEY_TYPE</action>
   3.440 -		</tree>
   3.441 -		<hbox>
   3.442 -			<text width-chars=\"65\">
   3.443 -				<label>
   3.444 -\"Favorite networks connect automatically when the computer is started           \"
   3.445 -				</label>
   3.446 -			</text>
   3.447 -		</hbox>
   3.448 -		<hbox>
   3.449 -			<text width-chars=\"50\">
   3.450 -				<label>
   3.451 -\"Please double click on a network to modify or remove it\"
   3.452 -				</label>
   3.453 -			</text>
   3.454 -			<button>
   3.455 -				<label>Add Network</label>
   3.456 -				<input file icon=\"gtk-add\"></input>
   3.457 -				<action>$0 add_favorite_network_box</action>
   3.458 -				<action>refresh:FAVORITE</action>
   3.459 -			</button>
   3.460 -		</hbox>
   3.461 -	</vbox>"
   3.462 -
   3.463 -	# Configuration tab
   3.464 -	WIFI_DIALOG=${WIFI_DIALOG}'
   3.465 -	<vbox>
   3.466 -		<frame Basic>
   3.467 -			<hbox>
   3.468 -				<text use-markup="true">
   3.469 -					<label>"<b>Interface:</b>"</label>
   3.470 -				</text>
   3.471 -				<entry>
   3.472 -					<input>. /etc/network.conf; echo "$WIFI_INTERFACE"</input>
   3.473 -					<variable>WIFI_INTERFACE</variable>
   3.474 -				</entry>
   3.475 -			</hbox>
   3.476 -			<hbox>
   3.477 -				<text use-markup="true">
   3.478 -					<label>"<b>ESSID:        </b>"</label>
   3.479 -				</text>
   3.480 -				<entry>
   3.481 -					<input>. /etc/network.conf; echo "$WIFI_ESSID"</input>
   3.482 -					<variable>WIFI_ESSID</variable>
   3.483 -				</entry>
   3.484 -			</hbox>
   3.485 -			<hbox>
   3.486 -				<text use-markup="true">
   3.487 -					<label>"<b>Key:           </b>"</label>
   3.488 -				</text>
   3.489 -				<entry>
   3.490 -					<input>. /etc/network.conf; echo "$WIFI_KEY"</input>
   3.491 -					<variable>WIFI_KEY</variable>
   3.492 -				</entry>
   3.493 -				<combobox>'
   3.494 -	tmp2="${WIFI_DIALOG}<item>$WIFI_KEY_TYPE</item>"
   3.495 -	for i in none WEP WPA any; do
   3.496 -		[ "$i" = "$WIFI_KEY_TYPE" ] || tmp2="$tmp2<item>$i</item>"
   3.497 -	done
   3.498 -	tmp3='		<variable>WIFI_KEY_TYPE</variable>
   3.499 -				</combobox>
   3.500 -			</hbox>
   3.501 -		</frame>
   3.502 -		<frame Advanced>
   3.503 -			<hbox>
   3.504 -				<text use-markup="true">
   3.505 -					<label>"<b>Channel/Mode:</b>"</label>
   3.506 -				</text>
   3.507 -				<entry>
   3.508 -					<input>. /etc/network.conf; echo "$WIFI_CHANNEL"</input>
   3.509 -					<variable>WIFI_CHANNEL</variable>
   3.510 -				</entry>
   3.511 -				
   3.512 -				<combobox>
   3.513 -					<variable>WIFI_MODE</variable>'
   3.514 -	tmp2="$tmp2$tmp3<item>$WIFI_MODE</item>"
   3.515 -	for i in managed ad-hoc master repeater secondary monitor; do
   3.516 -		[ "$i" = "$WIFI_MODE" ] || tmp2="$tmp2<item>$i</item>"
   3.517 -	done
   3.518 -	tmp3='		</combobox>
   3.519 -			</hbox>
   3.520 -			<hbox>
   3.521 -				<text use-markup="true">
   3.522 -					<label>"<b>Iwconfig args:</b> "</label>
   3.523 -				</text>
   3.524 -				<entry>
   3.525 -					<input>. /etc/network.conf; echo "$WIFI_IWCONFIG_ARGS"</input>
   3.526 -					<variable>WIFI_IWCONFIG_ARGS</variable>
   3.527 -				</entry>'
   3.528 -	WIFI_DIALOG="$tmp$tmp2$tmp3
   3.529 -	$(helpbutton iwconfig 80x24)
   3.530 -	$(manbutton 8 iwconfig)
   3.531 -			</hbox>
   3.532 -		</frame>"
   3.533 -		
   3.534 -	# Start Button for manual configuration.
   3.535 -	WIFI_DIALOG=${WIFI_DIALOG}'
   3.536 -		<hbox>
   3.537 -		   <button>
   3.538 -				<label>Save to Favorites</label>
   3.539 -				<input file icon="document-save"></input>
   3.540 -				<action>echo "# Wireless connection configuration." > $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.541 -				<action>echo "#" >> /etc/wireless/"$WIFI_ESSID".conf</action>
   3.542 -				<action>echo "WIFI_ESSID=\"$WIFI_ESSID\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.543 -				<action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.544 -				<action>echo "WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.545 -				<action>export FAVNET=$WIFI_ESSID; $BIN auto_connect_to_favorites_atboot</action>	
   3.546 -				<action>refresh:FAVORITE</action>
   3.547 -			</button>
   3.548 -			<button>
   3.549 -				<label>Start connection</label>
   3.550 -				<input file icon="forward"></input>
   3.551 -				<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>
   3.552 -				<action>sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/ /etc/network.conf</action>
   3.553 -				<action>sed -i s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/ /etc/network.conf</action>
   3.554 -				<action>sed -i s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/ /etc/network.conf</action>
   3.555 -				<action>sed -i s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/ /etc/network.conf</action>
   3.556 -				<action>sed -i s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/ /etc/network.conf</action>
   3.557 -				<action>sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" /etc/network.conf</action>
   3.558 -				<action>sed -i s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/ /etc/network.conf</action>
   3.559 -				<action>sed -i s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/ /etc/network.conf</action>
   3.560 -				<action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action>
   3.561 -				<action>ifconfig $WIFI_INTERFACE down</action>
   3.562 -				<action>iwconfig $WIFI_INTERFACE txpower auto</action>
   3.563 -				<action>/etc/init.d/network.sh restart</action>
   3.564 -				<action>refresh:ESSID_LIST</action>
   3.565 -				<action>refresh:WIFI_ESSID</action>
   3.566 -				<action>refresh:WIFI_KEY</action>
   3.567 -				<action>refresh:WIFI_KEY_TYPE</action>
   3.568 -			</button>
   3.569 -		</hbox>
   3.570 -	</vbox>'
   3.571 -
   3.572 -	# Kernel Modules, firmware and tazndisbox note + button.
   3.573 -	WIFI_DIALOG=${WIFI_DIALOG}"
   3.574 -	<vbox>
   3.575 -		<hbox>
   3.576 -			<text width-chars=\"64\">
   3.577 -				<label>
   3.578 -\"
   3.579 -Some Wireless Adapters need non-free firmware. Please install the
   3.580 -firmware before loading the corresponding module. Note that you can use 
   3.581 -Tazhw to automatically detect your PCI, PCMCIA or USB Wireless adapter.
   3.582 -\"
   3.583 -				</label>
   3.584 -			</text>
   3.585 -		</hbox>
   3.586 -		<hbox>
   3.587 -			<text use-markup=\"true\">
   3.588 -				<label>\"<b>Tools:</b>\"</label>
   3.589 -			</text>
   3.590 -			<button>
   3.591 -				<input file icon=\"computer\"></input>
   3.592 -				<label>Auto detect devices</label>
   3.593 -				<action>tazhw box</action>
   3.594 -				<action>refresh:ESSID_LIST</action>
   3.595 -			</button>"
   3.596 -			# Display firmware stuff, tazndisbox button if installed and close 
   3.597 -			# tab + notebook
   3.598 -			if [ -x /usr/bin/tazndisbox ]; then
   3.599 -				WIFI_DIALOG=${WIFI_DIALOG}"
   3.600 -			<button>
   3.601 -				<input file icon=\"system-installer\"></input>
   3.602 -				<label>Install Windows driver</label>
   3.603 -				<action>tazndisbox</action>
   3.604 -				<action>refresh:ESSID_LIST</action>
   3.605 -			</button>"
   3.606 -			fi
   3.607 -		WIFI_DIALOG=${WIFI_DIALOG}"
   3.608 -		</hbox>
   3.609 -		<hbox>
   3.610 -			<text use-markup=\"true\">
   3.611 -				<label>\"<b>Module:</b>\"</label>
   3.612 -			</text>
   3.613 -			<combobox>
   3.614 -				<variable>MODULE</variable>"
   3.615 -	WIFI_DIALOG="${WIFI_DIALOG}$(find /lib/modules/$(uname -r)/kernel/drivers/net/wireless -type f 2> /dev/null |  sed 's,/.*/\(.*\).ko.*,<item>\1</item>,')"
   3.616 -	WIFI_DIALOG=${WIFI_DIALOG}'
   3.617 -			</combobox>
   3.618 -			<button>
   3.619 -				<label>Load</label>
   3.620 -				<input file icon="forward"></input>
   3.621 -				<action>modprobe $MODULE</action>
   3.622 -			</button>
   3.623 -			<button>
   3.624 -				<label>Unload</label>
   3.625 -				<input file icon="undo"></input>
   3.626 -				<action>modprobe -r $MODULE</action>
   3.627 -			</button>
   3.628 -			<button>
   3.629 -				<label>Lsmod</label>
   3.630 -				<input file icon="computer"></input>
   3.631 -				<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title "Modules (q to quit)" -e "lsmod | less"</action>
   3.632 -			</button>
   3.633 -		</hbox>'
   3.634 -	# Firmware stuff.
   3.635 -	tmp=$(for i in /usr/bin/get*firmware; do
   3.636 -		[ -x $i ] || continue
   3.637 -		[ "$i" = "/usr/bin/get-wifi-firmware" ] && continue
   3.638 -		[ -d /var/lib/tazpkg/installed/${i#/usr/bin/get-} ] && continue
   3.639 -		echo "<item>${i#/usr/bin/get-}</item>"; done)
   3.640 -		[ -n "$tmp" ] && tmp="
   3.641 -		<hbox>
   3.642 -			<text use-markup=\"true\">
   3.643 -				<label>\"<b>Firmware:</b>\"</label>
   3.644 -			</text>
   3.645 -			<combobox><variable>FIRMWARE</variable>$tmp</combobox>
   3.646 -			<button>
   3.647 -				<label>Install</label>
   3.648 -				<input file icon=\"go-jump\"></input>
   3.649 -				<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title \"Install \$FIRMWARE\" -e \"get-\$FIRMWARE\"</action>
   3.650 -				<action>refresh:ESSID_LIST</action>
   3.651 -			</button>
   3.652 -			<button>
   3.653 -				<input file icon=\"system-file-manager\"></input>
   3.654 -				<label>List files</label>
   3.655 -				<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>
   3.656 -				<action>refresh:ESSID_LIST</action>
   3.657 -			</button>
   3.658 -		</hbox>"
   3.659 -
   3.660 -# Bottom buttons
   3.661 -export WIFI_DIALOG=${WIFI_DIALOG}${tmp}"
   3.662 -		</vbox>
   3.663 -	</notebook>
   3.664 -	<hbox>
   3.665 -		<button>
   3.666 -			<label>Stop connection</label>
   3.667 -			<input file icon=\"stop\"></input>
   3.668 -			<action>$0 stop_wifi_connexion</action>
   3.669 -			<action>refresh:ESSID_LIST</action>
   3.670 -		</button>
   3.671 -		<button>
   3.672 -			<label>Exit</label>
   3.673 -			<input file icon=\"exit\"></input>
   3.674 -			<action type=\"exit\">Exit</action>
   3.675 -		</button>
   3.676 -	</hbox>
   3.677 -	
   3.678 -</vbox>
   3.679 -</window>"
   3.680 -	gtkdialog --center --program=WIFI_DIALOG #>/dev/null 2>&1
   3.681 -}
   3.682 -
   3.683 -if [ -n "$1" ]; then
   3.684 -	$1
   3.685 -else
   3.686 -	box
   3.687 -fi
   3.688 -
   3.689 -exit 0