mirror of
https://github.com/SqrtMinusOne/dotfiles.git
synced 2025-12-10 19:23:03 +03:00
fix(ipstack-vpn): do not err on wrong JSON from API
This commit is contained in:
parent
770a2421a6
commit
0dc4420ecc
2 changed files with 10 additions and 2 deletions
|
|
@ -993,9 +993,13 @@ if [[ -z $ip || $ip == *"timed out"* ]]; then
|
|||
fi
|
||||
ip_info=$(curl -s http://api.ipstack.com/${ip}?access_key=${API_KEY})
|
||||
# emoji=$(echo $ip_info | jq -r '.location.country_flag_emoji')
|
||||
code=$(echo $ip_info | jq -r '.country_code')
|
||||
code=$(echo $ip_info | jq -r '.country_code' 2> /dev/null)
|
||||
vpn=$(pgrep -a openvpn$ | head -n 1 | awk '{print $NF }' | cut -d '.' -f 1)
|
||||
|
||||
if [[ -z $code ]]; then
|
||||
code="??"
|
||||
fi
|
||||
|
||||
if [ -n "$vpn" ]; then
|
||||
echo "%{u<<get-color(name="blue")>>}%{+u} $code %{u-}"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -9,9 +9,13 @@ if [[ -z $ip || $ip == *"timed out"* ]]; then
|
|||
fi
|
||||
ip_info=$(curl -s http://api.ipstack.com/${ip}?access_key=${API_KEY})
|
||||
# emoji=$(echo $ip_info | jq -r '.location.country_flag_emoji')
|
||||
code=$(echo $ip_info | jq -r '.country_code')
|
||||
code=$(echo $ip_info | jq -r '.country_code' 2> /dev/null)
|
||||
vpn=$(pgrep -a openvpn$ | head -n 1 | awk '{print $NF }' | cut -d '.' -f 1)
|
||||
|
||||
if [[ -z $code ]]; then
|
||||
code="??"
|
||||
fi
|
||||
|
||||
if [ -n "$vpn" ]; then
|
||||
echo "%{u#82aaff}%{+u} $code %{u-}"
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue