mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
theme(glowsticks): request timeout
This commit is contained in:
parent
9238f3adbf
commit
ff4ff26e3a
|
@ -103,15 +103,18 @@ blocks:
|
||||||
script: |
|
script: |
|
||||||
api_key="$OWM_API_KEY" # change this
|
api_key="$OWM_API_KEY" # change this
|
||||||
now=$(date +'%I:%M')
|
now=$(date +'%I:%M')
|
||||||
[[ $(date +'%p') == 'am' ]] && now+='滛' || now+=''
|
[[ $(date +'%p') == 'am' ]] && now+='滛 ' || now+=' '
|
||||||
[[ -z $api_key ]] && echo "$now" && exit
|
echo -n "$now"
|
||||||
|
[[ -z $api_key ]] && exit 0
|
||||||
update=$(jq '.minute' /tmp/weather.w | tr -d '"')
|
update=$(jq '.minute' /tmp/weather.w | tr -d '"')
|
||||||
if [[ -f '/tmp/weather.w' && $NO_WEATHER_CACHE -ne 1 && $(bc -l <<<"$(date +'%M')<=($update+10)") -eq 1 ]]; then
|
if [[ -f '/tmp/weather.w' && $NO_WEATHER_CACHE -ne 1 && $(bc -l <<<"$(date +'%M')<=($update+10)") -eq 1 ]]; then
|
||||||
echo $now "$(jq .weather /tmp/weather.w | tr -d '"')" && exit 0
|
echo -n "$(jq .weather /tmp/weather.w | tr -d '"')" && exit 0
|
||||||
else
|
else
|
||||||
location=$(curl -s 'https://freegeoip.live/json/')
|
location=$(curl -m .25 -s 'https://freegeoip.live/json/')
|
||||||
|
[[ $? -ne 0 ]] && echo -n '(睊)' && exit 0
|
||||||
url="https://api.openweathermap.org/data/2.5/weather?lat=$(echo "$location" | jq .latitude)&lon=$(echo "$location" | jq .longitude)&units=metric&appid=$api_key"
|
url="https://api.openweathermap.org/data/2.5/weather?lat=$(echo "$location" | jq .latitude)&lon=$(echo "$location" | jq .longitude)&units=metric&appid=$api_key"
|
||||||
res=$(curl -s "$url")
|
res=$(curl -m .25 -s "$url")
|
||||||
|
[[ $? -ne 0 ]] && echo -n '(睊)' && exit 0
|
||||||
temp=$(echo "$res" | jq .main.temp)
|
temp=$(echo "$res" | jq .main.temp)
|
||||||
temp_min=$(echo "$res" | jq .main.temp_min)
|
temp_min=$(echo "$res" | jq .main.temp_min)
|
||||||
temp_max=$(echo "$res" | jq .main.temp_max)
|
temp_max=$(echo "$res" | jq .main.temp_max)
|
||||||
|
@ -152,8 +155,8 @@ blocks:
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
weather="${icon} ${temp_s} ${feels_string}"
|
weather="${icon} ${temp_s} ${feels_string}"
|
||||||
echo -e "$now $weather"
|
echo -ne "$weather"
|
||||||
echo -e "{\"minute\": \"$(date +'%M')\", \"weather\": \"$weather\"}" >/tmp/weather.w
|
echo -ne "{\"minute\": \"$(date +'%M')\", \"weather\": \"$weather\"}" >/tmp/weather.w
|
||||||
fi
|
fi
|
||||||
style: diamond
|
style: diamond
|
||||||
template: "{{ .Output }}"
|
template: "{{ .Output }}"
|
||||||
|
@ -161,7 +164,7 @@ blocks:
|
||||||
type: command
|
type: command
|
||||||
type: rprompt
|
type: rprompt
|
||||||
final_space: true
|
final_space: true
|
||||||
console_title_template: " {{ .Shell }} in {{ if ne .Folder \"~\"}} {{ .Folder }}{{else}}{{end}}"
|
console_title_template: {{ .Shell }} in {{ if ne .Folder "~"}} {{ .Folder }}{{else}}{{end}}
|
||||||
palette:
|
palette:
|
||||||
black: "#33395b"
|
black: "#33395b"
|
||||||
blue: "#359ddd"
|
blue: "#359ddd"
|
||||||
|
|
Loading…
Reference in a new issue