fnandot / gnome-shell-extension-nightscout

A GNOME Shell Extension which integrates Nightscout into your panel.
GNU General Public License v3.0
4 stars 7 forks source link

Please update to latest Gnome 4x #5

Open alfureu opened 3 years ago

alfureu commented 3 years ago

Please update to the latest Gnome 4x, this is essential app. Using Fedora and I cannot install (with an error: incompatible)

luavreis commented 2 years ago

@DOFfactory see #6

rgamaro commented 1 year ago

Please update to the latest Gnome 4x, this is essential app. Using Manjaro and I cannot install (with an error: incompatible)

alfureu commented 1 year ago

If this helps, I opted at the end to use the widget Executor: https://extensions.gnome.org/extension/2932/executor/

In the widget I am calling a simple bash script nightscout-widget.sh every 120 seconds:

#!/bin/bash
# <xbar.title>Nightscout Reader</xbar.title>
# <xbar.version>0.2.0</xbar.version>
# <xbar.desc>For Diabetics using Nightscout to track CGM data: Display current Blood Sugar data and trend from Nightscout</xbar.desc>
# <xbar.dependencies>bash, curl, bc, jq</xbar.dependencies>
# <xbar.author>Jeremy Hay Draude</xbar.author>
# <xbar.author.github>jhaydraude</xbar.author.github>
# <xbar.image>https://raw.githubusercontent.com/jhaydraude/NightscoutBitBar/master/Preview.png</xbar.image>
# <xbar.abouturl>https://github.com/jhaydraude/NightscoutBitBar/blob/master/README.md</xbar.abouturl>

export PATH="/usr/local/bin:/usr/bin:$PATH"

if ! [ -x "$(command -v jq)" ]; then
  echo 'Error: jq is not installed.'
  echo '---'
#  echo 'Click here to install jq | href=https://stedolan.github.io/jq/download/'
  exit 1
fi

NSURL=YOUR SERVER ADDRESS WITH HTTPS # Add your own Nightscout URL here
TOKEN=YOUR NS API TOKEN GENERATED UNDER NS>ADMIN TOOLS
USEMMOL=true # true if you use mmol/l units. false if you use mg/dl

JSONOUT=$(curl --silent $NSURL/api/v1/entries/current.json?token=$TOKEN)

EPOCHNOW=$(date +%s) # Convert current time to epoch time

BG=$(jq '.[0].sgv' <<< "$JSONOUT")

TRENDSTR=$(jq -r '.[0].direction' <<< "$JSONOUT")

if $USEMMOL ; then
    BG=$(echo "scale=1; $BG / 18" | bc) #Convert mg/dl to mmol/l
fi

case $TRENDSTR in
    FortyFiveUp)
        TREND='↗'
        ;;
    FortyFiveDown)
        TREND='↘'
        ;;
    SingleUp)
        TREND='↑'
        ;;
    SingleDown)
        TREND='↓'
        ;;
    Flat)
        TREND='→'
        ;;
    DoubleUp)
        TREND='⇈'
        ;;
    DoubleDown)
        TREND='⇊'
        ;;
    *)
        TREND=$TRENDSTR
        ;;
esac

echo "$BG $TREND"
# echo "---"
# echo "Go to Nightscout | href=$NSURL"
# echo "Reading taken: $TIMESTRING"

You have to install jq, but in most cases it is already a part of a linux system.

All credit goes to Jeremy Hay Draude, who is the original author of this script, I just adjusted it for Linux

Cybereu commented 1 year ago

@DOFfactory Worked great, TY!