Skip to content

GENERICERROR000/gdbg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gdbg

red blood drop with text 'gdbg' centered

overview

gdbg: get dexcom blood glucose

a python app that displays blood glucose in the macos menu bar. retrieves blood glucose from dexcom via the pydexcom library. it also writes the blood glucose and trend arrow to a state file that can be used for displaying data in your terminal (or anything else you want).

this app was inspired by kylebshr/luka-mini. this is a fantastic app and would recommend for people who want a seamless app experience. i wanted to be able to access the blood glucose data outside of the app for other uses.

screenshot of menu bar app in use

screenshot of blood sugar in terminal prompt

how to use

  1. download zip from releases

  2. unzip and move to Applications folder

  3. setup credentials

this file must be created manually

  • ~/.dexcom/dexcom_credentials.json
{
  "username" : "dexcom_username",
  "password": "dexcom_password"
}
  1. run app or add it to your login items on mac

blood glucose state file

this file is generated by the app

  • ~/.dexcom/bg_status.txt

format of the status is: [bg] [delta] [trend arrow] '[reading timestamp]'

the delta starts at 0 and will show change after second reading is retrieved.

using in zsh $PROMPT

# ~/.zshrc

function get_bg() {
    RED='\033[91m'
    GREEN='\033[92m'
    YELLOW='\033[93m'
    END='\033[0m'

    state_file=$(cat $HOME/.dexcom/bg_status.txt)
    value=$(echo "$state_file" | cut -d' ' -f1)
    delta=$(echo "$state_file" | cut -d' ' -f2)
    arrow=$(echo "$state_file" | cut -d' ' -f3)

    if [[ $value -ge 80 && $value -le 180 ]]; then
        color="$GREEN"
    elif [[ $value -gt 180 ]]; then
        color="$YELLOW"
    elif [[ $value -lt 80 ]]; then
        color="$RED"
    fi

    echo "${color}${value} (${delta}) ${arrow}${END}"
}

# backslash in `\$(...)` is required for the value to update every time 
export PROMPT="$PROMPT\$(get_bg)"

manually building macos statusbar app

using anaconda on macos

# (1) create virtual environment
conda create --name gdbg python=3.11
conda activate gdbg

# (2) install requirements
pip install --no-cache-dir -r requirements.txt

# (3) build app
python macos_statusbar/setup.py py2app -A

# (4) run app from terminal to see errors
dist/gdbg.app/Contents/MacOS/gdbg

known issues

when building, if you get the error that the library libffi.8.dylib is missing, you can install it with brew.

brew install libffi

credits

assets

packages

references

TODO

(1)

  • how to handle stale data?
    • show data is stale after 10 ior 15 min?

(2)

  • linux version (branch:gnome_extension)
    • run dexcom_handler.py as service
    • create gnome top bar extension
    • use timestamp in state file for "last updated"
    • update readme