mirror of
https://github.com/liclac/ambient
synced 2024-11-22 03:43:19 +00:00
ambient_get_ssid: fall back to nmcli if iw has no ssid
This commit is contained in:
parent
942e6da0c9
commit
027fa3c088
1 changed files with 11 additions and 2 deletions
|
@ -1,9 +1,18 @@
|
|||
function ambient_get_ssid
|
||||
if not set -q ambient_ssid
|
||||
if test (uname) = "Darwin"
|
||||
if test (uname) = "Darwin" # On macOS, query the airport tool.
|
||||
set -g ambient_ssid (/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -n 's/^ *SSID: //p')
|
||||
else
|
||||
set -g ambient_ssid (iw dev | grep ssid | sed -n 's/^\s*ssid //p')
|
||||
# Try to get the SSID via `iw`. This is the quickest, most widely supported option.
|
||||
if command -q iw
|
||||
set -g ambient_ssid (iw dev | grep ssid | sed -n 's/^\s*ssid //p' | string trim)
|
||||
end
|
||||
|
||||
# In some setups (why?), `iw dev` can't show an SSID. Try querying NetworkManager?
|
||||
if test -z $ambient_ssid; and command -q nmcli
|
||||
set -g ambient_ssid (nmcli -t -f type,name connection show --active |\
|
||||
string match -rg '802-11-wireless:(.*)')
|
||||
end
|
||||
end
|
||||
end
|
||||
echo $ambient_ssid
|
||||
|
|
Loading…
Reference in a new issue