slitaz-tools view tinyutils/wifibox @ rev 340
tazx: Moved doc to Handbook
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Mon May 04 23:12:18 2009 +0200 (2009-05-04) |
parents | c32ad66d6096 |
children | afbb699cfd0f |
line source
1 #!/bin/sh
2 #
3 # GTKdialog interface to manage wireless connections in a simple way.
4 # Use tabs to indent, split commands from the GUI and use functions.
5 # Favorite networks are also supported
6 #
7 # (c) 2009 SliTaz GNU/Linux - GNU gpl v3
8 #
9 VERSION=20090222
11 # Export script path and others if needed so we can use them in 'quote'.
12 export BIN=$0
13 export FAVORITES_WIFI=/etc/wireless
14 . /etc/network.conf
16 # Wifibox is only for root.
17 if test $(id -u) != 0 ; then
18 exec subox wifibox
19 exit 0
20 fi
22 # Sanity check
23 [ -x /usr/sbin/iwconfig ] || tazpkg get-install wireless_tools
24 [ -d $FAVORITES_WIFI ] || mkdir -p $FAVORITES_WIFI
25 rm -f $FAVORITES_WIFI/any.conf
27 # Catch ESSIDs and format output for GTK tree. We get the list of
28 # networks by Cell and without spaces.
29 detect_wifi_networks()
30 {
31 desktopbox notify "Scanning Wireless interface: $WIFI_INTERFACE" &
32 if [ -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
33 ifconfig $WIFI_INTERFACE up
34 for i in `iwlist $WIFI_INTERFACE scan | sed s/"Cell "/Cell-/ | grep "Cell-" | awk '{print $1}'`
35 do
36 SCAN=`iwlist $WIFI_INTERFACE scan last | sed s/"Cell "/Cell-/ | grep -A 8 "$i"`
37 ESSID=`echo $SCAN | cut -d '"' -f 2`
38 if echo "$SCAN" | grep -q Quality; then
39 QUALITY=`echo $SCAN | sed 's/.*Quality=\([^ ]*\).*/\1/' | sed 's/.*Quality:\([^ ]*\).*/\1/'`
40 else
41 QUALITY="-"
42 fi
43 ENCRYPTION=`echo $SCAN | sed 's/.*key:\([^ ]*\).*/\1/'`
44 # Check encryption type
45 if echo "$SCAN" | grep -q WPA; then
46 ENCRYPTION="${ENCRYPTION} (WPA)"
47 fi
48 # Connected or not connected...
49 if ifconfig | grep -A 1 $WIFI_INTERFACE | \
50 grep -q inet && iwconfig $WIFI_INTERFACE | \
51 grep ESSID | grep -q -w "$ESSID"; then
52 STATUS=connected
53 else
54 STATUS="-"
55 fi
56 echo -n ""
57 echo "$ESSID | $QUALITY | $ENCRYPTION | $STATUS"
58 done
59 fi
60 }
62 # cmdline functions
64 # Toggle Software RF Switch on some laptops
65 set_rfswitch()
66 {
67 for i in /proc/driver/acerhk/wirelessled /proc/acpi/asus/wled ; do
68 [ -e $i ] && echo $1 > $i
69 done
70 }
72 # Configure /etc/network.conf and restart connection with init script.
73 start_wifi_connection()
74 {
75 # Get tmp config created by connect_to_essid() if exists and set
76 # empty value to clean config file.
77 if [ -f /tmp/wifi.conf ]; then
78 . /tmp/wifi.conf
79 WIFI_MODE=""
80 WIFI_IWCONFIG_ARGS=""
81 WIFI_CHANNEL=""
82 fi
83 sed -i "s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/" \
84 /etc/network.conf
85 sed -i "s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/" \
86 /etc/network.conf
87 sed -i "s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/" \
88 /etc/network.conf
89 sed -i "s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/" \
90 /etc/network.conf
91 sed -i "s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/" \
92 /etc/network.conf
93 sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" \
94 /etc/network.conf
95 sed -i "s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/" \
96 /etc/network.conf
97 sed -i "s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/" \
98 /etc/network.conf
99 [ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`
100 ifconfig $WIFI_INTERFACE down
101 set_rfswitch 1
102 iwconfig $WIFI_INTERFACE txpower auto
103 /etc/init.d/network.sh restart
104 # Remove tmp file (could be used to have wireless profiles)
105 rm -f /tmp/wifi.conf
106 }
108 # We must sleep 4 sec to refresh networks list.
109 stop_wifi_connexion()
110 {
111 sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"no\"/ \
112 /etc/network.conf
113 [ -x /etc/init.d/wpa_supplicant ] && /etc/init.d/wpa_supplicant stop
114 ifconfig $WIFI_INTERFACE down
115 iwconfig $WIFI_INTERFACE txpower off
116 set_rfswitch 0
117 [ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`
118 sleep 4
119 }
121 # Favorite wireless networks use only 3 values: essid. key and type of
122 # key
123 FAVORITES_WIFI_list()
124 {
125 for i in $FAVORITES_WIFI/*.conf
126 do
127 WIFI_ESSID=""
128 WIFI_KEY=""
129 WIFI_KEY_TYPE=""
130 . "$i"
131 [ -z "$WIFI_ESSID" ] && WIFI_ESSID="Bad config file: $i"
132 [ -z "$WIFI_KEY_TYPE" ] && WIFI_KEY_TYPE="-"
133 if [ -n "$WIFI_KEY" ]; then
134 WIFI_KEY="********"
135 else
136 WIFI_KEY="-"
137 fi
138 echo "$WIFI_ESSID | $WIFI_KEY_TYPE | $WIFI_KEY"
139 done
140 }
142 favorite_wifi_actions()
143 {
144 cp -a $FAVORITES_WIFI/"$FAVORITE".conf /tmp/wifi.conf
145 . /tmp/wifi.conf
146 export CONNECT_FAVORITE="
147 <window title=\"Connect to: $WIFI_ESSID\" icon-name=\"network-wireless\">
148 <vbox>
150 <text width-chars=\"54\">
151 <label>
152 \"
153 ESSID name: $WIFI_ESSID
154 \"
155 </label>
156 </text>
158 <hbox>
159 <button>
160 <label>Connect</label>
161 <input file icon=\"forward\"></input>
162 <action>$0 start_wifi_connection</action>
163 <action type=\"exit\">exit</action>
164 </button>
165 <button>
166 <label>Edit settings</label>
167 <input file icon=\"accessories-text-editor\"></input>
168 <action>leafpad $FAVORITES_WIFI/\"$FAVORITE\".conf</action>
169 <action>rm -f /tmp/wifi.conf</action>
170 <action type=\"exit\">exit</action>
171 </button>
172 <button>
173 <label>Delete</label>
174 <input file icon=\"gtk-delete\"></input>
175 <action>rm -f $FAVORITES_WIFI/\"$FAVORITE\".conf</action>
176 <action type=\"exit\">exit</action>
177 </button>
178 <button cancel></button>
179 </hbox>
181 </vbox>
182 </window>"
183 gtkdialog --center --program=CONNECT_FAVORITE >/dev/null
184 }
186 add_favorite_network_box()
187 {
188 ADD_FAVORITE='
189 <window title="Add new favorite Wireless" icon-name="network-wireless">
190 <vbox>
191 <text width-chars="54">
192 <label>
193 "
194 Please configure your new favorite Wireless network
195 "
196 </label>
197 </text>
198 <hbox>
199 <text use-markup="true">
200 <label>"<b>ESSID:</b>"</label>
201 </text>
202 <entry>
203 <variable>WIFI_ESSID</variable>
204 </entry>
205 </hbox>
206 <hbox>
207 <text use-markup="true">
208 <label>"<b>Key: </b>"</label>
209 </text>
210 <entry>
211 <variable>WIFI_KEY</variable>
212 </entry>
213 </hbox>
214 <hbox>
215 <text use-markup="true">
216 <label>"<b>Key type:</b>"</label>
217 </text>
218 <combobox>'
219 tmp="${ADD_FAVORITE}<item>$WIFI_KEY_TYPE</item>"
220 for i in none WEP WPA any; do
221 tmp=${tmp}"<item>$i</item>"
222 done
223 export ADD_FAVORITE=${tmp}'
224 <variable>WIFI_KEY_TYPE</variable>
225 </combobox>
226 </hbox>
227 <hbox>
228 <button>
229 <label>Add to list</label>
230 <input file icon="forward"></input>
231 <action>echo "# Wireless connection configuration." > $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
232 <action>echo "#" >> /etc/wireless/"$WIFI_ESSID".conf</action>
233 <action>echo "WIFI_ESSID=\"$WIFI_ESSID\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
234 <action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
235 <action>echo "WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
236 <action type="exit">exit</action>
237 </button>
238 <button cancel></button>
239 </hbox>
240 </vbox>
241 </window>'
242 gtkdialog --center --program=ADD_FAVORITE #>/dev/null
243 }
245 # GUI functions
247 helpbutton()
248 {
249 local label;
250 label="<label>$3</label>"
251 [ -n "$3" ] || label=""
252 cat << EOT
253 <button>
254 <input file icon="help"></input>$label
255 <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>
256 </button>
257 EOT
258 }
260 manbutton()
261 {
262 cat << EOT
263 <button>
264 <input file icon="browser"></input>
265 <label>man</label>
266 <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>
267 </button>
268 EOT
269 }
271 # Independant dialog to connect on a wireless network. If encryption
272 # is on we ask for the security key.
273 connect_to_essid()
274 {
275 SCAN=`iwlist $WIFI_INTERFACE scanning essid "$ESSID_LIST" | grep -A 6 "ESSID"`
276 WIFI_ESSID="$ESSID_LIST"
277 ENCRYPTION=`echo $SCAN | sed 's/.*key:\([^ ]*\).*/\1/'`
278 # Create tmp file used by active_wifi_connexion()
279 cat > /tmp/wifi.conf << _EOF_
280 # Wireless connexion configuration file.
281 WIFI_ESSID="$ESSID_LIST"
282 _EOF_
283 CONNECT_ESSID="
284 <window title=\"Connect to: $WIFI_ESSID\" icon-name=\"network-wireless\">
285 <vbox>
286 <text width-chars=\"54\">
287 <label>
288 \"
289 Connect $WIFI_INTERFACE to: $WIFI_ESSID
290 \"
291 </label>
292 </text>"
293 # We maybe need a key to connect
294 if [ "$ENCRYPTION" = "on" ] && [ "$ESSID_LIST" != "any" ]; then
295 # WPA
296 if echo "$SCAN" | grep -q WPA; then
297 echo 'WIFI_KEY_TYPE="WPA"' >> /tmp/wifi.conf
298 CONNECT_ESSID=${CONNECT_ESSID}'
299 <hbox>
300 <text use-markup="true">
301 <label>"<b>WPA Key:</b>"</label>
302 </text>
303 <entry>
304 <input>. /etc/network.conf; echo "$WIFI_KEY"</input>
305 <variable>WIFI_KEY</variable>
306 </entry>
307 </hbox>'
308 else
309 # WEP
310 echo 'WIFI_KEY_TYPE="WEP"' >> /tmp/wifi.conf
311 CONNECT_ESSID=${CONNECT_ESSID}'
312 <hbox>
313 <text use-markup="true">
314 <label>"<b>WEP Key:</b>"</label>
315 </text>
316 <entry>
317 <input>. /etc/network.conf; echo "$WIFI_KEY"</input>
318 <variable>WIFI_KEY</variable>
319 </entry>
320 </hbox>'
321 fi
322 else
323 # No encryption
324 echo 'WIFI_KEY=""' >> /tmp/wifi.conf
325 echo 'WIFI_KEY_TYPE=""' >> /tmp/wifi.conf
326 start_wifi_connection
327 exit 0
328 fi
329 # Add key to config file so active_wifi_connexion() can use it.
330 # WIFI_KEY is not exported if we quote with --> "
331 export CONNECT_ESSID=${CONNECT_ESSID}'
332 <hbox>
333 <button>
334 <label>Connect</label>
335 <input file icon="forward"></input>
336 <action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> /tmp/wifi.conf</action>
337 <action>$BIN start_wifi_connection</action>
338 <action type="exit">exit</action>
339 </button>
340 <button cancel></button>
341 </hbox>
342 </vbox>
343 </window>'
344 gtkdialog --center --program=CONNECT_ESSID #>/dev/null
345 }
347 # Wifibox start with Networks tab.
348 box()
349 {
350 WIFI_DIALOG="
351 <window title=\"Wireless manager\" icon-name=\"network-wireless\">
352 <vbox>
354 <notebook labels=\"Networks|Favorites|Configuration|Drivers\">
356 <vbox>
357 <tree icon=\"network-wireless\">
358 <width>500</width><height>160</height>
359 <variable>ESSID_LIST</variable>
360 <label>ESSID|Quality|Encryption|Status</label>
361 <input>$0 detect_wifi_networks</input>
362 <item icon=\"network-wireless\">any | * | off | (auto-connect)</item>
363 <action>$0 connect_to_essid</action>
364 <action>refresh:ESSID_LIST</action>
365 <action>refresh:WIFI_ESSID</action>
366 <action>refresh:WIFI_KEY</action>
367 <action>refresh:WIFI_KEY_TYPE</action>
368 </tree>
369 <hbox>
370 <text width-chars=\"50\">
371 <label>
372 \"Please double click on a network to connect or enter security key\"
373 </label>
374 </text>
375 <button>
376 <label>Refresh list</label>
377 <input file icon=\"reload\"></input>
378 <action>refresh:ESSID_LIST</action>
379 </button>
380 </hbox>
381 </vbox>"
383 # Favorite networks
384 WIFI_DIALOG=${WIFI_DIALOG}"
385 <vbox>
386 <tree icon=\"network-wireless\">
387 <width>500</width><height>160</height>
388 <variable>FAVORITE</variable>
389 <label>ESSID|Key Type|Key status</label>
390 <input>$0 FAVORITES_WIFI_list</input>
391 <item icon=\"network-wireless\">any | - | -</item>
392 <action>$0 favorite_wifi_actions</action>
393 <action>refresh:FAVORITE</action>
394 <action>refresh:ESSID_LIST</action>
395 <action>refresh:WIFI_ESSID</action>
396 <action>refresh:WIFI_KEY</action>
397 <action>refresh:WIFI_KEY_TYPE</action>
398 </tree>
399 <hbox>
400 <text width-chars=\"50\">
401 <label>
402 \"Please double click on a network to modify or remove it\"
403 </label>
404 </text>
405 <button>
406 <label>Add Network</label>
407 <input file icon=\"gtk-add\"></input>
408 <action>$0 add_favorite_network_box</action>
409 <action>refresh:FAVORITE</action>
410 </button>
411 </hbox>
412 </vbox>"
414 # Configuration tab
415 WIFI_DIALOG=${WIFI_DIALOG}'
416 <vbox>
417 <frame Basic>
418 <hbox>
419 <text use-markup="true">
420 <label>"<b>Interface:</b>"</label>
421 </text>
422 <entry>
423 <input>. /etc/network.conf; echo "$WIFI_INTERFACE"</input>
424 <variable>WIFI_INTERFACE</variable>
425 </entry>
426 </hbox>
427 <hbox>
428 <text use-markup="true">
429 <label>"<b>ESSID: </b>"</label>
430 </text>
431 <entry>
432 <input>. /etc/network.conf; echo "$WIFI_ESSID"</input>
433 <variable>WIFI_ESSID</variable>
434 </entry>
435 </hbox>
436 <hbox>
437 <text use-markup="true">
438 <label>"<b>Key: </b>"</label>
439 </text>
440 <entry>
441 <input>. /etc/network.conf; echo "$WIFI_KEY"</input>
442 <variable>WIFI_KEY</variable>
443 </entry>
444 <combobox>'
445 tmp2="${WIFI_DIALOG}<item>$WIFI_KEY_TYPE</item>"
446 for i in none WEP WPA any; do
447 [ "$i" = "$WIFI_KEY_TYPE" ] || tmp2="$tmp2<item>$i</item>"
448 done
449 tmp3=' <variable>WIFI_KEY_TYPE</variable>
450 </combobox>
451 </hbox>
452 </frame>
453 <frame Advanced>
454 <hbox>
455 <text use-markup="true">
456 <label>"<b>Channel/Mode:</b>"</label>
457 </text>
458 <entry>
459 <input>. /etc/network.conf; echo "$WIFI_CHANNEL"</input>
460 <variable>WIFI_CHANNEL</variable>
461 </entry>
463 <combobox>
464 <variable>WIFI_MODE</variable>'
465 tmp2="$tmp2$tmp3<item>$WIFI_MODE</item>"
466 for i in managed ad-hoc master repeater secondary monitor; do
467 [ "$i" = "$WIFI_MODE" ] || tmp2="$tmp2<item>$i</item>"
468 done
469 tmp3=' </combobox>
470 </hbox>
471 <hbox>
472 <text use-markup="true">
473 <label>"<b>Iwconfig args:</b>"</label>
474 </text>
475 <entry>
476 <input>. /etc/network.conf; echo "$WIFI_IWCONFIG_ARGS"</input>
477 <variable>WIFI_IWCONFIG_ARGS</variable>
478 </entry>'
479 WIFI_DIALOG="$tmp$tmp2$tmp3
480 $(helpbutton iwconfig 80x24)
481 $(manbutton 8 iwconfig)
482 </hbox>
483 </frame>"
485 # Start Button for manual configuration.
486 WIFI_DIALOG=${WIFI_DIALOG}'
487 <hbox>
488 <button>
489 <label>Start connection</label>
490 <input file icon="forward"></input>
491 <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>
492 <action>sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/ /etc/network.conf</action>
493 <action>sed -i s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/ /etc/network.conf</action>
494 <action>sed -i s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/ /etc/network.conf</action>
495 <action>sed -i s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/ /etc/network.conf</action>
496 <action>sed -i s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/ /etc/network.conf</action>
497 <action>sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" /etc/network.conf</action>
498 <action>sed -i s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/ /etc/network.conf</action>
499 <action>sed -i s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/ /etc/network.conf</action>
500 <action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action>
501 <action>ifconfig $WIFI_INTERFACE down</action>
502 <action>iwconfig $WIFI_INTERFACE txpower auto</action>
503 <action>/etc/init.d/network.sh restart</action>
504 <action>refresh:ESSID_LIST</action>
505 <action>refresh:WIFI_ESSID</action>
506 <action>refresh:WIFI_KEY</action>
507 <action>refresh:WIFI_KEY_TYPE</action>
508 </button>
509 </hbox>
510 </vbox>'
512 # Kernel Modules, firmware and tazndisbox note + button.
513 WIFI_DIALOG=${WIFI_DIALOG}"
514 <vbox>
515 <hbox>
516 <text width-chars=\"64\">
517 <label>
518 \"
519 Some Wireless Adapters need non-free firmware. Please install the
520 firmware before loading the corresponding module. Note: you can use
521 Tazhw to automatically detect your PCI, PCMCIA or USB Wireless adapter.
522 \"
523 </label>
524 </text>
525 </hbox>
526 <hbox>
527 <text use-markup=\"true\">
528 <label>\"<b>Tools:</b>\"</label>
529 </text>
530 <button>
531 <input file icon=\"computer\"></input>
532 <label>Auto detect devices</label>
533 <action>tazhw box</action>
534 <action>refresh:ESSID_LIST</action>
535 </button>"
536 # Display firmware stuff, tazndisbox button if installed and close
537 # tab + notebook
538 if [ -x /usr/bin/tazndisbox ]; then
539 WIFI_DIALOG=${WIFI_DIALOG}"
540 <button>
541 <input file icon=\"system-installer\"></input>
542 <label>Install Windows driver</label>
543 <action>tazndisbox</action>
544 <action>refresh:ESSID_LIST</action>
545 </button>"
546 fi
547 WIFI_DIALOG=${WIFI_DIALOG}"
548 </hbox>
549 <hbox>
550 <text use-markup=\"true\">
551 <label>\"<b>Module:</b>\"</label>
552 </text>
553 <combobox>
554 <variable>MODULE</variable>"
555 WIFI_DIALOG="${WIFI_DIALOG}$(find /lib/modules/$(uname -r)/kernel/drivers/net/wireless -type f 2> /dev/null | sed 's,/.*/\(.*\).ko.*,<item>\1</item>,')"
556 WIFI_DIALOG=${WIFI_DIALOG}'
557 </combobox>
558 <button>
559 <label>Load</label>
560 <input file icon="forward"></input>
561 <action>modprobe $MODULE</action>
562 </button>
563 <button>
564 <label>Unload</label>
565 <input file icon="undo"></input>
566 <action>modprobe -r $MODULE</action>
567 </button>
568 <button>
569 <label>Lsmod</label>
570 <input file icon="computer"></input>
571 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title "Modules (q to quit)" -e "lsmod | less"</action>
572 </button>
573 </hbox>'
574 # Firmware stuff.
575 tmp=$(for i in /usr/bin/get*firmware; do
576 [ -x $i ] || continue
577 [ "$i" = "/usr/bin/get-wifi-firmware" ] && continue
578 [ -d /var/lib/tazpkg/installed/${i#/usr/bin/get-} ] && continue
579 echo "<item>${i#/usr/bin/get-}</item>"; done)
580 [ -n "$tmp" ] && tmp="
581 <hbox>
582 <text use-markup=\"true\">
583 <label>\"<b>Firmware:</b>\"</label>
584 </text>
585 <combobox><variable>FIRMWARE</variable>$tmp</combobox>
586 <button>
587 <label>Install</label>
588 <input file icon=\"go-jump\"></input>
589 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title \"Install \$FIRMWARE\" -e \"get-\$FIRMWARE\"</action>
590 <action>refresh:ESSID_LIST</action>
591 </button>
592 <button>
593 <input file icon=\"system-file-manager\"></input>
594 <label>List files</label>
595 <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>
596 <action>refresh:ESSID_LIST</action>
597 </button>
598 </hbox>"
600 # Bottom buttons
601 export WIFI_DIALOG=${WIFI_DIALOG}${tmp}"
602 </vbox>
603 </notebook>
604 <hbox>
605 <button>
606 <label>Stop connection</label>
607 <input file icon=\"stop\"></input>
608 <action>$0 stop_wifi_connexion</action>
609 <action>refresh:ESSID_LIST</action>
610 </button>
611 <button>
612 <label>Exit</label>
613 <input file icon=\"exit\"></input>
614 <action type=\"exit\">Exit</action>
615 </button>
616 </hbox>
618 </vbox>
619 </window>"
620 gtkdialog --center --program=WIFI_DIALOG >/dev/null 2>&1
621 }
623 if [ -n "$1" ]; then
624 $1
625 else
626 box
627 fi
629 exit 0