This Python script is a plugin for xbar or swiftbar that allows you to pull recent blood glucose values from Dexcom Share and display them in the Mac menubar:
The design is based heavily on the Nightscout-based menubar apps by Mark Wilson and Michael Pangburn.
By default,the script runs once per minute to update the displayed age of the BG values, but tries to minimize network requests by only downloading new BGs if the most recent reading is more than four minutes old. Current values are cached in a text file in /tmp.
- A working Python 3 installation. While Python is no longer included by default with the Mac OS, you can install it from the Xcode command-line tools, homebrew, or Anaconda.
- The pydexcom package. Install it with
pip install pydexcom. - A working Dexcom Share setup that is uploading your blood glucose values (or those of someone who has given you access to their data) to the cloud.
I have submitted this to the repository of xbar plugins for inclusion there, but alternatively you can:
- Copy the Dexcom_BG.1m.py script to
~/Library/Application Support/xbar/plugins/. - Make the script executable by running in the Terminal:
chmod +x ~/Library/Application\ Support/xbar/plugins/Dexcom_BG.1m.py - Set your Dexcom Share username and password via accessing the plugin in the xbar interface, or by editing the script directly and changing
VAR_USERNAMEandVAR_PASSWORD. Be aware that your username and password will be stored on your computer in plain text, so there is a potential security risk of running this on a computer that others have access to. - Optionally, set
VAR_REGIONto "ous" or "jp" if you are not in the United States. - Optionally, set
VAR_MMOLto "true" if you prefer to display BG in units of mmol/L instead of mg/dL. - Launch xbar, and if you wish, set it to launch automatically at login.
The output of the script is simply text, and xbar handles putting that into the menu bar. If things don't seem to be running properly, see if you can run the script in the Terminal. You should see some text output to the screen.
If xbar is running but you don't see anything in the menubar, see the issue below.
- On some M1 (and later) MacBooks that have a "notch" for the camera in the menubar area, xbar may place the menubar output in the invisible notch region. This is general xbar issue that affects all plugins. If you start this plugin but don't see any output, try quitting xbar, removing other icons from the menu bar and re-launching xbar. You can then re-add your other icons, which hopefully are notch-aware and will move accordingly.
Enjoy! If you have any questions or problems, please open an issue here.
