A compact Scriptable Lock Screen widget that shows the percentage remaining in your Codex usage windows:
The Mac refreshes the data every 15 minutes while awake. Scriptable syncs it to the iPhone through iCloud Drive.
- macOS and iPhone signed into the same iCloud account
- Scriptable installed on the iPhone with iCloud enabled
- ChatGPT or Codex desktop app installed in
/Applicationsand signed in - Python 3 on Mac
This project uses the Codex executable bundled with the Codex (now inside ChatGPT) desktop app. It does not install or require a separate Codex CLI, and it does not copy or expose authentication tokens.
-
Open Scriptable once on the iPhone and enable iCloud for Scriptable.
-
Clone this repository inside Codex and run:
chmod +x install.sh ./install.sh
-
If macOS asks, allow Terminal or Codex to access iCloud Drive and install the user LaunchAgent.
-
On the iPhone, open Scriptable and run Codex Usage once.
-
Long-press the Lock Screen, choose Customize, tap the widget area, add Scriptable, choose the rectangular widget, and select Codex Usage.
| Item | Location |
|---|---|
| Widget script | ~/Library/Mobile Documents/iCloud~dk~simonbs~Scriptable/Documents/Codex Usage.js |
| Mac updater | ~/.local/share/codex-usage-widget/codex_usage_to_icloud.py |
| Usage data | Scriptable's iCloud folder as codex-limits.json |
| LaunchAgent | ~/Library/LaunchAgents/com.openai.codex-usage-widget.plist |
| Logs | /tmp/codex-usage-widget.log and /tmp/codex-usage-widget.err |
The LaunchAgent uses StartInterval = 900, so it runs every 15 minutes while the Mac is awake. iOS controls the exact Lock Screen widget refresh time.
Run the updater manually:
~/.local/share/codex-usage-widget/codex_usage_to_icloud.pyCheck the generated data and service:
ls -l "$HOME/Library/Mobile Documents/iCloud~dk~simonbs~Scriptable/Documents/codex-limits.json"
launchctl print "gui/$(id -u)/com.openai.codex-usage-widget"
tail -n 20 /tmp/codex-usage-widget.log
tail -n 20 /tmp/codex-usage-widget.errIf the installer or updater cannot access Scriptable's iCloud folder and reports Operation not permitted, allow the desktop app running Codex to access iCloud Drive:
- Open System Settings → Privacy & Security → Files & Folders.
- Select ChatGPT (or Codex, if shown separately).
- Enable iCloud Drive.
- Run the installer or updater again.
If no iCloud Drive toggle appears under Files & Folders, open System Settings → Privacy & Security → Full Disk Access, enable ChatGPT or Codex there, then retry.
The Scriptable folder used by this project is:
~/Library/Mobile Documents/iCloud~dk~simonbs~Scriptable/Documents
- Percentages are percentage remaining, not percentage used.
05Hshows its local reset time only when Codex supplies one.07Dshows its local reset date asDD.MM.- Missing reset information is omitted.
launchctl bootout "gui/$(id -u)" "$HOME/Library/LaunchAgents/com.openai.codex-usage-widget.plist" 2>/dev/null || true
rm -f "$HOME/Library/LaunchAgents/com.openai.codex-usage-widget.plist"
rm -rf "$HOME/.local/share/codex-usage-widget"
rm -f "$HOME/Library/Mobile Documents/iCloud~dk~simonbs~Scriptable/Documents/Codex Usage.js"The uninstall commands intentionally leave codex-limits.json in place. Remove it separately if desired.