You are not logged in.
I found the Wireless autodetection article on ArchWiki and didn't feel like finding MAC addresses for all the access points that I use, so I modified the netdetect script to look like this:
#!/bin/bash
. /etc/rc.conf
aSCANNEDESSIDS=(`iwlist eth1 scanning | grep ESSID | cut -d \" -f 2 | sed "s/ /_/g"`)
for J in ${aSCANNEDESSIDS[*]} ; do
DET_ESSID=`cat /etc/network-profiles/$aSCANNEDESSIDS | grep ESSID= | tr -d ESSID= | sed "s/ //g"`
if [ $DET_ESSID ]
then
FOUNDESSID=$aSCANNEDESSIDS
break
fi
done
if [ $FOUNDESSID ]
then
netcfg -c $FOUNDESSID
else
echo "Known AP not detected: using wired connection"
netcfg -c Ethernet
fi
Usage notes:
- The script matches a found ESSID by files in /etc/network-profiles/, so you'll need profiles that match the name of the ESSID you're trying to connect to. The only exception is ESSID names with spaces, in which you'll need to replace the space with an underscore (_).
- My wired profile is named "Ethernet", as opposed to "lan-dhcp". Change it to what you need.
- Notice that there's no priority for the scanned ESSIDs. This can easily be fixed by adding a variable in rc.conf (something like "aKNOWNESSIDS") then comparing what's on that list to the list of scanned ESSIDs, just like the original netdetect does.
- You are free to use as you want. Just let me know if you make any improvements ;)
Also, if anyone can help me with reading spaces in the names so that I don't have to use underscores, that'd be really helpful. Thanks :D
Offline