Skip to content

Commit

Permalink
wifi: further cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
romkatv committed Sep 1, 2020
1 parent cababbe commit 47c842f
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions internal/p10k.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -4940,15 +4940,7 @@ _p9k_prompt_wifi_async() {
SSID) ssid=$v;;
esac
done
if [[ $state != running || $rssi != (0|-<->) || $noise != (0|-<->) ]]; then
rssi=
noise=
last_tx_rate=
link_auth=
ssid=
return 0
fi
on=1
[[ $state == running && $rssi == (0|-<->) && $noise == (0|-<->) ]] || return 0
elif [[ -r /proc/net/wireless && -n $commands[iw] ]]; then
# Content example (https://github.com/romkatv/powerlevel10k/pull/973#issuecomment-680251804):
#
Expand All @@ -4963,11 +4955,7 @@ _p9k_prompt_wifi_async() {
state=${parts[2]}
rssi=${parts[4]%.*}
noise=${parts[5]%.*}
if [[ -z $iface || $state != 0## || $rssi != (0|-<->) || $noise != (0|-<->) ]]; then
rssi=
noise=
return 0
fi
[[ -n $iface && $state == 0## && $rssi == (0|-<->) && $noise == (0|-<->) ]] || return 0
# Output example (https://github.com/romkatv/powerlevel10k/pull/973#issuecomment-680251804):
#
# Connected to 74:83:c2:be:76:da (on wlp3s0)
Expand All @@ -4992,14 +4980,7 @@ _p9k_prompt_wifi_async() {
[[ $last_tx_rate == <->.<-> ]] && last_tx_rate=${${last_tx_rate%%0#}%.}
fi
done
if [[ -z $ssid || -z $last_tx_rate ]]; then
rssi=
noise=
ssid=
last_tx_rate=
return 0
fi
on=1
[[ -n $ssid && -n $last_tx_rate ]] || return 0
else
return 0
fi
Expand All @@ -5017,7 +4998,16 @@ _p9k_prompt_wifi_async() {
else
bars=0
fi
on=1
} always {
if (( ! on )); then
rssi=
noise=
ssid=
last_tx_rate=
bars=
link_auth=
fi
if [[ $_p9k__wifi_on != $on ||
$P9K_WIFI_LAST_TX_RATE != $last_tx_rate ||
$P9K_WIFI_SSID != $ssid ||
Expand Down

0 comments on commit 47c842f

Please sign in to comment.