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.
-
download zip from releases
-
unzip and move to
Applications folder
-
setup credentials
this file must be created manually
~/.dexcom/dexcom_credentials.json
{
"username" : "dexcom_username",
"password": "dexcom_password"
}
- run app or add it to your login items on mac
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.
# ~/.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)"
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
when building, if you get the error that the library libffi.8.dylib
is missing, you can install it with brew
.
brew install libffi
assets
- logo by izzy bulling - @izval
- modak font used in logo
packages
- kylebshr/luka-mini
- Create a macOS Menu Bar App with Python (Pomodoro Timer) - Camillo Visini
- Glucose Readings in a Terminal Prompt - Hart Hoover
(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
- run