Last active
May 24, 2021 19:55
-
-
Save alexsorokoletov/3fa2b5d784ab569151fd7093d3fc947f to your computer and use it in GitHub Desktop.
xbar bitbar plugin for wifi speed and name - I use it to find weak wifi spots or confirm that the wifi signal jumps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# <bitbar.title>WiFi level</bitbar.title> | |
# <bitbar.version>v1.0</bitbar.version> | |
# <bitbar.author>Alex Sorokoletov</bitbar.author> | |
# <bitbar.author.github>alexsorokoletov</bitbar.author.github> | |
# <bitbar.desc>TX rate/Link speed of the connected WiFi</bitbar.desc> | |
# <bitbar.dependencies></bitbar.dependencies> | |
# <bitbar.abouturl>https://sorokoletov.com/</bitbar.abouturl> | |
# Kudos to https://github.com/Powerlevel9k/powerlevel9k/issues/317 | |
# place this file in /Users/user/bitbar-plugins/ | |
zsh_wifi_signal(){ | |
local output=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I) | |
local airport=$(echo $output | grep 'AirPort' | awk -F': ' '{print $2}') | |
local theme=$(defaults read -g AppleInterfaceStyle 2>&1) | |
if [ "$airport" = "Off" ]; then | |
if [ "$theme" = "Dark" ]; then | |
echo -n "Wifi Off|color=white" | |
else | |
echo -n "Wifi Off|color=black" | |
fi | |
else | |
local ssid=$(echo "$output" | grep ' SSID' | awk -F': ' '{print $2}') | |
local speed=$(echo "$output" | grep 'lastTxRate' | awk -F': ' '{print $2}') | |
local color='color=yellow' | |
[[ $speed -gt 100 ]] && color='color=green' | |
[[ $speed -lt 50 ]] && color='color=red' | |
echo "$ssid $speed Mb/s|$color" | |
fi | |
} | |
zsh_wifi_signal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You might want to change
color=green
tocolor=limegreen
based on your dark/light theme and color preferences.