dotfiles/polybar/scripte/nightscout_cgm.sh

37 lines
750 B
Bash
Executable file

#!/bin/bash
api_url=$(curl -s -X GET "https://nightscout.mgrote.net/api/v1/entries/sgv?count=1&token=polybar-ae6fe2720f2c30f4")
#echo $api_url
if [ $? -ne 0 ]; then
echo "---"
else
symbol=$(echo $api_url | awk '{print $4}')
#echo $symbol
wert=$(echo $api_url | awk '{printf "%.1f\n",$3*0.0555}')
#echo $wert
case $symbol in
'"SingleDown"')
echo $wert "⇓"
;;
'"SingleUp"')
echo $wert "⇑"
;;
'"DoubleDown"')
echo $wert "⇓⇓"
;;
'"DoubleUp"')
echo $wert "⇑⇑"
;;
'"FortyFiveDown"')
echo $wert "⇘"
;;
'"FortyFiveUp"')
echo $wert "⇗"
;;
'"Flat"')
echo $wert "⇒"
;;
*)
echo $symbol
;;
esac
fi