Just thought i would share this. I like to turn off wireless networking when its not being used to save power and unnecessary radiation so i used this wifi toggle script so i could use the SES button on my Lynksys WRT54G to turn it on and off easily. It still got left on most of the time though so i made a script to turn it off automatically when its not being used. It needs to be run on cron every 5 minutes and it will turn the wireless off if no-one has been connected for between 5 and 10 minutes.
#!/bin/sh if [ $(cat /proc/diag/led/ses_white | tr -d '\n') -eq 1 ] # check if wifi is on then echo "Wifi is on" if [ -z "$(wlc assoclist | tr -d '\n')" ] # Check if anyone is connected then echo "No-one is connected" case "$(cat /var/autowifi)" in # check if anyone was connected 5 mins ago 1) echo "No-one was connected 5 minutes ago so turning off wireless" /sbin/woggle cat </dev/null > /var/autowifi ;; *) echo "Someone was connected 5 minutes ago so leaving wireless on for now" echo 1 > /var/autowifi ;; esac else echo "Someone is connected" fi else echo "Wifi is already off" fi
I saved the script at /sbin/autowifi and added the following in crontab:
*/5 * * * * /sbin/autowifi
And you might want to 'touch /var/autowifi' so you don't get errors when it is checked for the first time. I hope this helps someone.