An open API service indexing awesome lists of open source software.

https://github.com/genericerror000/gdbg

get dexcom blood glucose
https://github.com/genericerror000/gdbg

dexcom gnome-shell-extension macos pydexcom

Last synced: 29 days ago
JSON representation

get dexcom blood glucose

Awesome Lists containing this project

README

          

# gdbg

red blood drop with text 'gdbg' centered

## overview

> gdbg: *get dexcom blood glucose*

a python service that retrieves/displays blood glucose from dexcom via the [pydexcom](https://github.com/gagebenne/pydexcom) library and writes it (and other info) to state file. the state file can then be used for displaying data in your terminal (or anything else you want).

this app was inspired by [kylebshr/luka-mini](https://github.com/kylebshr/luka-mini/tree/main). this is a *fantastic* app i and would recommend it 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 blood sugar in terminal prompt

## how to use

1. clone repo

2. set up environment

```sh
python3 -m venv gdbg

source gdbg/bin/activate
```

3. install requirements

```sh
pip install -r requirements.txt
```

4. setup credentials

*__this file must be created manually__*

`~/.dexcom/dexcom_credentials.json`

```json
{
"username" : "",
"password": ""
}
```

5. run via cli

```sh
python cgm_service.py
```

## blood glucose state file

this file is generated by the app if set to write state

* `~/.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.

### example usage in zsh $PROMPT

```sh
# ~/.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)"
```

## references

* [kylebshr/luka-mini](https://github.com/kylebshr/luka-mini/tree/main)
(https://camillovisini.com/coding/create-macos-menu-bar-app-pomodoro)
* [Glucose Readings in a Terminal Prompt - Hart Hoover](https://harthoover.com/glucose-readings-in-a-terminal-prompt/)

## credits

assets

* logo by [izzy bulling - @izval](https://www.instagram.com/izval/)
* [modak](https://github.com/EkType/Modak) font used in logo

packages

* [gagebenne/pydexacom](https://github.com/gagebenne/pydexcom)

created by

* [GENERIC_ERROR](https://generic_error.xyz/)

-//-

## TODO:

* [ ] testing