Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codex Account Switcher Logo

Codex Account Switcher

A premium, native macOS menu bar utility to switch active Codex accounts in a single click.

Swift macOS MIT License Build Status Dependencies

Key Features • How It Works • Installation • Development • License


📖 Overview

Codex Account Switcher is an ultra-lightweight, blazing-fast macOS menu bar utility built in pure Swift. It eliminates the friction of managing multiple OpenAI Codex / ChatGPT credentials on your local machine.

With zero external dependencies and a footprint under 300 KB, it integrates directly with macOS system APIs to hot-swap account tokens, safely restart active desktop applications, and display real-time usage budgets directly in your status bar.


✨ Key Features

🎛️ One-Click Account Switching

  • Instantly swap between saved profiles with a single click from the menu bar.
  • Automatically terminates, purges, and restarts the active Codex desktop app to apply the new session.

🎨 Redesigned Menu UI

  • Account cards — Each account is shown as a rich card with a coloured avatar circle (deterministic hue from your email), email, plan badge, and a green Active pill.
  • Glass-effect usage bars — Animated progress bars with gradient fills and a liquid-glass specular highlight stripe that fill with a smooth ease-out cubic animation when the menu opens.
  • Section headers — Styled uppercase labels with SF Symbol icons for visual hierarchy.
  • SF Symbol icons on all action items for a native macOS look.

🌗 Dark & Light Mode

  • Full adaptive rendering for both macOS appearances.
  • Avatar colours, glass highlights, progress bars, and all text use dynamic NSColor providers and semantic system colours that automatically adjust.

🔄 Smooth Animations

  • Braille spinner (⠋ ⠙ ⠹ ⠸ ⠼ ⠴ …) rotating at 80 ms intervals during account switches.
  • Core Animation opacity pulse on the status-bar button while switching (0.7 s ease-in-out cycle).
  • Crossfade title transitions — status-bar text fades out, swaps, then fades back in.
  • Animated progress fill — usage bars sweep from zero with an ease-out cubic curve on menu open.
  • All timers registered in .common run-loop mode so animations keep running even during menu tracking.

📊 Real-Time Usage Tracking

  • Track remaining 5-Hour and Weekly usage limits directly in the status bar.
  • Select which metric appears in the menu bar by clicking the corresponding usage row.
  • When API data is unavailable, usage is displayed as NIL with a dashed placeholder bar instead of misleading zeroes.

🔁 Custom Menu Bar Icon

  • Crisp, template-mode SF Symbol icon (arrow.triangle.2.circlepath) that automatically adapts to light/dark menu bar and highlights.
  • Falls back to a hand-drawn CoreGraphics glyph if SF Symbols are unavailable.

🗺️ Smart Environment Detection

  • Zero hardcoding: Dynamically traverses your local nvm (~/.nvm) Node installations (sorted latest-first) to locate codex-auth.
  • Intelligent shell fallback: Falls back to an interactive zsh login shell (/bin/zsh -l) to resolve PATH if customised.

🏷️ Custom Account Labels

  • Add custom aliases, numbers, or emojis (e.g. 01, Work, 🚀) to identify accounts instantly in the status bar.

⚙️ How It Works

The Swift menu bar app orchestrates token swapping and app lifecycle management securely via local POSIX subprocess bindings:

[ macOS Menu Bar ]
       │
       ├─► [1] Snapshots active token to per-account storage (base64-keyed)
       ├─► [2] Calls `codex-auth switch <selector>` to swap credentials
       ├─► [3] Terminates Codex processes (SIGTERM → SIGKILL, filtering own PID)
       ├─► [4] Relaunches via `codex-auth app` with `open -a` fallback
       └─► [5] Runs braille spinner + CA opacity pulse on the main run loop

🚀 Installation

1. Clone the repository

git clone https://github.com/MohamedFuad16/Codex-Acc-Switcher.git
cd Codex-Acc-Switcher

2. Build the Application Bundle

./build.sh

This compiles Sources/main.swift with swiftc and assembles Codex Account Switcher.app in ./build/.

3. Deploy to Applications

./install.sh

Copies the app to ~/Applications/.

4. Run without installing

./run.sh

🛠️ Development

This utility is built entirely in Swift with zero external dependencies — no CocoaPods, no SPM packages, no dynamic frameworks. It compiles directly with swiftc for an incredibly responsive, native app with negligible memory footprint.

Language Swift 5.9+
Frameworks AppKit, QuartzCore (Core Animation)
Compiler swiftc targeting arm64-apple-macosx14.0
Min OS macOS 14.0 (Sonoma)
Dependencies None
App size < 300 KB

Project Structure

Sources/
  main.swift          — Single-file app: data models, custom views, app delegate
build.sh              — Compiles + assembles .app bundle with Info.plist
install.sh            — Copies built app to ~/Applications
run.sh                — Build + launch in one step

📝 License

This project is licensed under the MIT License. See the LICENSE file for details.

Developed with ❤️ by MohamedFuad16. Contributions and issues are always welcome!

About

Codex account switching tool

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages