Skip to content

Commit

Permalink
Merge pull request #355 from gavink97/main
Browse files Browse the repository at this point in the history
Fixed a bug handling air segment text
  • Loading branch information
erikw authored Jan 23, 2024
2 parents b0063ed + 8bdcf8f commit 42f06c1
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions segments/air.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ __get_us_aqi_score() {
fi

aqi_value=$(__get_aqi_max "$carbon_monoxide_aqi_value" "$nitrogen_dioxide_aqi_value" "$ozone_aqi_value" "$sulphur_dioxide_aqi_value" "$fine_particle_aqi_value" "$coarse_particulate_aqi_value")
IFS=' ' read -r aqi_level aqi_color aqi_symbol <<< "$(__get_aqi_level_color_symbol "$aqi_value")"
# aqi_value=150
IFS=' ' read -r aqi_color aqi_symbol <<< "$(__get_aqi_level_color_symbol "$aqi_value")"
rounded_aqi=$(printf '%.*f\n' 0 "$aqi_value")

echo "${rounded_aqi} AQI ${aqi_symbol}" "${aqi_color}" | tee "${tmp_file}"
Expand Down Expand Up @@ -272,36 +273,36 @@ __get_aqi_level_color_symbol(){
local aqi_value=$1

if (( $(echo "$aqi_value < 51" | bc -l) )); then
aqi_level="Good"
# aqi_level="Good"
aqi_color="#8da101" # Green
aqi_symbol="😊"
elif (( $(echo "$aqi_value < 101" | bc -l) )); then
aqi_level="Moderate"
# aqi_level="Moderate"
aqi_color="#dfa000" # Yellow
aqi_symbol="😐"
elif (( $(echo "$aqi_value < 151" | bc -l) )); then
aqi_level="Unhealthy for sensitive groups"
# aqi_level="Unhealthy for sensitive groups"
aqi_color="#f57d26" # Orange
aqi_symbol="🙁"
elif (( $(echo "$aqi_value < 201" | bc -l) )); then
aqi_level="Unhealthy"
# aqi_level="Unhealthy"
aqi_color="#f85552" # Red
aqi_symbol="😷"
elif (( $(echo "$aqi_value < 301" | bc -l) )); then
aqi_level="Very unhealthy"
# aqi_level="Very unhealthy"
aqi_color="#df69ba" # Purple
aqi_symbol="😨"
elif (( $(echo "$aqi_value < 501" | bc -l) )); then
aqi_level="Hazardous"
aqi_color="#542d2c" # Maroon
# aqi_level="Hazardous"
aqi_color="#883A26" # Maroon
aqi_symbol="🛑"
elif (( $(echo "$aqi_value < 1001" | bc -l) )); then
aqi_level="Very Hazardous"
# aqi_level="Very Hazardous"
aqi_color="#66401a" # Brown
aqi_symbol="💀"
fi

echo $aqi_level $aqi_color $aqi_symbol
echo $aqi_color $aqi_symbol
}

__read_tmp_file() {
Expand Down

0 comments on commit 42f06c1

Please sign in to comment.