Skip to content

Instantly share code, notes, and snippets.

@kirelagin
Last active August 17, 2019 22:43
Show Gist options
  • Save kirelagin/6a575ad6dcb5be8540dc70d8992f926a to your computer and use it in GitHub Desktop.
Save kirelagin/6a575ad6dcb5be8540dc70d8992f926a to your computer and use it in GitHub Desktop.
Monitor signal strength (RSSI) of the active Wi-Fi network on macOS
#!/bin/bash
# SPDX-FileCopyrightText: 2019 Kirill Elagin <https://kir.elagin.me/>
# SPDX-License-Identifier: MPL-2.0
###
#
# Monitor signal strength (RSSI) of the active Wi-Fi network on macOS.
#
# Usage:
# rssi.sh
#
# https://gist.github.com/kirelagin/6a575ad6dcb5be8540dc70d8992f926a
###
airport() { /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport "$@"; }
plistb() { /usr/libexec/PlistBuddy "$@"; }
tmpf=$(mktemp -t rssi.sh) # PlistBuddy can't read from stdin :/
tput civis # hide the cursor
trap 'tput cnorm; rm -f "$tmpf"; trap - INT; kill -s INT "$$"' INT
while true; do
airport -xI > "$tmpf"
sig=$(plistb -c 'Print :RSSI_CTL_AGR' "$tmpf"); printf "%s\r" "$sig"
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment