login

Apple's Airport: RSSI to %

I use Geektool in Mac OS X as a conky alternative, so I wrote a script that shows percentage of wireless signal.


#!/bin/bash

# apple airport rssi/dbm to signal percentage convert
# useful for geektool :)
# (tested on macbook5,1's airport (probably with Broadcom 4322?) & wl500gp)

# by howite@howite.org

# grabbing rssi value from active AP
sig=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | grep -e "agrCtlRSSI:" | awk '{print $2}'`

# grabbing rssi value from any other AP
#ssid="WLAN_Mike"
#sig=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -s | grep -e $ssid | awk '{print $3}'`
#
#if [ "$sig" == "" ]
#then
# #AP not found
# exit
#fi

# my own old poor values -_-
#min=80
#max=15

# cisco aironet 350 (seems it's more accurate?)
# ref.: http://www.cisco.com/en/US/docs/voice_ip_comm/cuipph/7920/5_0/english/design/guide/wrlradio.html#wp1041819
min=113
max=10

echo "$min $max $sig"|awk '{print int((100 / ($1 + -$2)) * ($1 + $3)) "%"}'


07.02.2009 16:44:01 / 0 comments / permalink