wlan-ui.pl - UI for selecting and connecting to WLAN access points (APs)
wlan-ui.pl -key my_essid=1234567890 -list my_essid
Options:
-help print help message and quit -man full documentation and quit -verbose more messages, more detailed help output -quiet no messages during operation -version returns version no -key ESSID=wep_key_value pairs -passwd ESSID=password pairs -list specify ESSID to put at top of list for connect -rescan_interval interval (in seconds) to rescan if no APs found -rescan_count number of times to rescan if no APs found -quit_on_connect whether to quit program when successfully connected -autoconnect try to connect to any APs listed as good for autoconnect -autoconnect_to give ESSID name of AP for which to try autoconnect -noui just do autoconnect, don't start UI for connect if fails @configfile
Options configuration file containing any of the options above in format given by Getopts::Argvfile E<lt>www.cpan.orgE<gt> - the format is the same as for the command line, but allowing multiple lines and comments.
key(s)
to use for connecting to a particular ESSID; e.g.
wlan-ui.pl -key my_essid=1234567890 -key other_essid=0987654321
password(s)
to use for connecting to a particular ESSID; e.g.
wlan-ui.pl -passwd my_essid=my_pass1 -key other_essid=my_pass2
wlan-ui.pl -list my_essid -list other_essid
The APs are listed in the order they appear on the command line (or in the options file - see below). APs are only listed if they also appear in the interface scan results. APs not specified using the -list option, but detected by the interface scan, are listed in order of signal strength.
wlan-ui.pl -autoconnect_to my_essid -autoconnect_to other_essid
wlan-ui.pl uses two types of configuration file, a system configuration file (see INSTALLATION below), and option configuration files, described here.
Option configuration files can specify options in the same format as for the command line, except options can be specified across many lines, and comments can be interposed: e.g
wlan-ui.pl -verbose @myconfig
where ``myconfig'' might be the following text file
# Configuration file for wlan-ui perl program -key "my_essid"='1234567890' -key 'test essid'='0987654321' -list my_essid -list other_essid -autoconnect_to my_essid -autoconnect
This file sets the WEP keys for my_essid and test_essid, puts my_essid and other_essid at the top of listed APs (if they turn up on a scan), and will attempt to connect to my_essid on startup.
Configuration files are read in the following order: .wlan-ui.pl in the directory of the wlan-ui.pl script; .wlan-ui.pl in your home directory; .wlan-ui.pl in the current directory; and any configuration file passed on the command line. Options in files read later override those in earlier files. Options passed on the command line override options passed in .wlan-ui.pl files, and any options specified earlier on the the command line than the @configfile item.
You will need various CPAN modules installed <http://www.cpan.org>:
Gtk2 Gtk2::GladeXML IO::Select Digest::MD5 Getopt::ArgvFile Pod::Usage
Installation is simple and inelegant. Copy the program file (wlan-ui.pl) to a directory on your path. Next, create a new system configuration file to reflect your system. The system configuration file is different from the options configuration file (@configfile, above). The system configuration file tells the program how to configure the wireless interface, and the options configuration file sets defaults for access points and other things. The default location of the system configuration file is /etc/wlan-uirc; you can change this by editing the contents of the $sys_config variable in the program file. Below is an example file, which uses the ipw2200 module <http://ipw2100.sourceforge.net> as my wireless driver. By default this gives me a network device attached to 'wlan0'.
# Example system configuration file # Edit and save as /etc/wlan-uirc
# Wireless driver module to load $MODULE = 'ipw2200';
# Module parameters $MODULEPARAMS = '';
# Wireless network device - e.g. 'wlan0'. # If not defined we use /proc/net/wireless to find the device $DEVICE = undef;
# Commands for manipulating wlan module etc # We will find unspecified commands from the path $CMDS = {'lsmod', '/sbin/lsmod', 'modprobe', '/sbin/modprobe', 'load', undef, # modprobe used by default 'unload', undef, # modprobe -r used by default 'iwconfig', '/sbin/iwconfig', 'iwlist', '/sbin/iwlist', 'ifconfig', '/sbin/ifconfig', 'ps', undef, 'dhcpcd', '/sbin/dhclient'};
The 'load' and 'unload' commands are usually left undefined, as above, but if you want to use scripts, you can define them. For example, the driverloader wireless driver <http://www.linuxant.com> uses a system init script to start and stop the wireless driver. To make this work, you could try something like:
$MODULE = 'driverloader'; $CMDS = {'lsmod', '/sbin/lsmod', 'modprobe', undef, # not needed in this case 'load', "/sbin/service $MODULE start", 'unload', "/sbin/service $MODULE stop", ...
Note the quotes (``) around the load and unload command, to allow variable substitution.
If you leave the $DEVICE variable undefined, the script will try and find your wireless network device using the /proc/net/wireless interface. If this fails, you will get messages including ``WLAN device not found'', and will need to set the $DEVICE variable to the name of your wireless interface (e.g. $DEVICE = 'wlan0';).
You can leave $MODULE undefined, in which case the wireless interface is assumed to be always up, and no attempt is made to check, unload etc, and you don't need to define lsmod; modprobe; load; unload.
wlan-ui.pl will need root permissions to run the various wireless configuration programs. I do this by giving myself sudo permission to run the script. Here's some excerpts from my /etc/sudoers file:
# Host alias specification Host_Alias LAPTOP = fetastra
# User alias specification User_Alias WIRELESS = myself, myfriend
# Run wlan-ui WIRELESS LAPTOP = NOPASSWD: /usr/local/bin/wlan-ui.pl
I can then run wlan-ui.pl with
sudo /usr/local/bin/wlan-ui.pl
For some security, make sure wlan-ui.pl is writeable only by root.
Note that the system configuration file (/etc/wlan-uirc) can contain commands that will be executed from within the program. You may want to make sure that the configuration file is only writeable by root.
wlan-ui.pl is a program to connect to wireless networks. It can be run as a GUI which will offer a list of available networks to connect to.
wlan-ui.pl is based on wlan-zenity, written by Mirza Muharemagic <http://www.php.co.ba/X31> and released under the BSD license.
See description of options for list of features.
We don't currently use the MAC address of the AP when connecting. This will give odd effects when there is more than one AP with the same ESSID. Search for the get_ap_by_essid function in the wlan-ui.pl file to see where this will cause a problem.
Matthew Brett <matthewb berkeley.edu>
Mirza Muharemagic <http://www.php.co.ba/X31>
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License distributed with Perl version 5.003 or (at your option) any later version. Please refer to the Artistic License that came with your Perl distribution for more details.