Displays information regarding your Cowboy bike in the MacOS menubar. Allows you to remotely control your Cowboy bike as well.
Update 2021.11.02:
- Xbar compatible
Update 2019.08.11:
- Show bike model, serial, mac address, odometer, co2 saved
- Enable continuous bike tracking
- Fix OS X dark mode icon
Update 2019.07.26:
- alpha version
- Initial import
Samuel Dumont's python Cowboy class.
-
Ensure you have xbar installed.
-
Install the Python deps:
pip3 install requests tinydb keyring googlemaps
-
Copy mycowboy.15m.py and the
library/directory to your xbar plugins folder andchmod +xthe script. (You can rename the file to change the refresh interval — e.g.mycowboy.6h.pyfor every six hours.) -
Run xbar and click "Login to Cowboy". The first-run flow stores your credentials in the macOS keychain and then prompts (optionally) for two Google API keys — see below.
The plugin uses two Google APIs:
| Feature | API | Where it's used |
|---|---|---|
| Inline map / satellite image | Maps Static API | the two thumbnails under the location submenu |
| Human-readable address | Geocoding API | the "Address:" line under the location submenu |
Both are optional. If neither key is configured the plugin still renders bike + battery + location coordinates, just without the map and address.
- Open the Google Cloud Console.
- Create (or pick) a project, then Enable APIs:
- Maps Static API
- Geocoding API
- Create Credentials → API key. Two separate keys are recommended so
each can be restricted to a single API:
- Key 1: API restriction → Maps Static API
- Key 2: API restriction → Geocoding API
- Optionally add an Application restriction (e.g. your IP address).
The plugin reads keys in this order: environment variable → macOS keychain → not configured.
Click Settings → Update Google API keys in the menu. A terminal window
opens and prompts for each key (leave blank to keep the current value).
Internally this runs mycowboy.15m.py keys.
security add-generic-password -s mycowboy-bitbar -a google_static_key -w 'YOUR_STATIC_MAPS_KEY' -U
security add-generic-password -s mycowboy-bitbar -a google_geocode_key -w 'YOUR_GEOCODING_KEY' -UInspect or revoke later via Keychain Access.app (search for mycowboy-bitbar)
or:
security find-generic-password -s mycowboy-bitbar -a google_static_key -w
security delete-generic-password -s mycowboy-bitbar -a google_static_keySet these in your shell profile (or xbar's plugin environment):
export MYCOWBOY_GOOGLE_STATIC_KEY="YOUR_STATIC_MAPS_KEY"
export MYCOWBOY_GOOGLE_GEOCODE_KEY="YOUR_GEOCODING_KEY"Environment variables override keychain values, which is handy for testing without touching the keychain.
The bottom of the plugin menu exposes a Settings submenu:
- Update Google API keys — re-runs
mycowboy.15m.py keys(Option A above). - Sign out & re-login — re-runs
mycowboy.15m.py initto refresh Cowboy credentials and (optionally) the Google keys.
| Item | Location |
|---|---|
| Cowboy username / password | macOS keychain (service mycowboy-bitbar) |
| Cached auth token | macOS keychain (service mycowboy-bitbar, account auth_token) |
| Google Maps / Geocoding keys | macOS keychain (accounts google_static_key, google_geocode_key) |
| Location history | ~/.state/mycowboy/mycowboy-locations.json (TinyDB) |
| Geocode cache | ~/.state/mycowboy/mycowboy-geoloc.json (TinyDB) |
| Static map PNG cache (per rounded coordinate, per month) | ~/.state/mycowboy/mycowboy-location-*.png |
