Build a macOS menu bar app that monitors typing system-wide and automatically hyperlinks mentions of the currently playing Spotify song. The key UX principle: preserve the user's natural language by hyperlinking their actual words (e.g., "this song", the song title, artist name) rather than appending robotic URLs.
When messaging/emailing people, users want to share what they're listening to without breaking their communication flow. Instead of copying Spotify links, the app detects when they mention their current song and makes that text clickable.
"I'm obsessed with this song https://open.spotify.com/track/abc123"
"I'm obsessed with [this song](spotify link)" ← "this song" is hyperlinked
- Use CGEventTap or Accessibility API to monitor typing across all apps
- Requires Accessibility permissions from user
- Buffer the last 10-20 words typed to detect patterns
- Use Spotify Web API to fetch currently playing track every 30 seconds
- Store: track name, artist, album, Spotify URL (https://open.spotify.com/track/...)
- User provides Spotify API token on first launch
Detect and hyperlink when user types:
- Exact song title: "Blinding Lights" → hyperlink it
- Natural references: "this song", "this track", "it" (if contextually about music)
- Artist name: "The Weeknd" → hyperlink to current song
- Partial matches: "blinding" → fuzzy match to "Blinding Lights"
Use simple keyword matching or lightweight fuzzy string matching (no LLM needed).
- Wait for user to type space/punctuation after matched phrase
- Replace the detected text with hyperlinked version
- Format varies by app:
- Slack/Discord:
<https://spotify.link/abc|Song Name> - Markdown apps:
[Song Name](https://spotify.link/abc) - iMessage/WhatsApp/Email: Plain URL with text (auto-previews)
- Default: Markdown format (most compatible)
- Slack/Discord:
- Wait 300-500ms after space/punctuation to confirm match
- Optional: Show subtle menu bar indicator when match detected
- Optional: User can disable with hotkey if false positive
- Language: Swift (native macOS)
- UI: Menu bar app (NSStatusItem)
- APIs: CGEventTap or NSAccessibility, Spotify Web API
- Permissions: Accessibility, Network access
- User launches app, grants Accessibility permission
- User logs in with Spotify API token (store in Keychain)
- App runs in menu bar, monitors:
- Current Spotify track (poll every 30s)
- User's typing (CGEventTap)
- When typing detected, buffer recent words
- When match found (song title/artist/reference):
- Wait for space/punctuation
- Replace text with hyperlinked version
- Format based on detected app context
- User types naturally, links appear automatically
- Toggle on/off
- Spotify login/logout
- Sensitivity (exact match vs fuzzy)
- Excluded apps (where not to monitor)
- Hotkey to manually insert current song link
- Working macOS app (.app bundle)
- Spotify API integration with OAuth flow
- Global keyboard monitoring with text replacement
- Menu bar UI with settings
- Brief README with setup instructions
Build this as quickly as possible with a focus on the core functionality working smoothly. Start with exact song title matching, then add fuzzy matching if time permits.
The SpotifyHyperlink app has been fully implemented with all requested features:
- ✅ Menu bar app with system tray icon
- ✅ Global keyboard monitoring using CGEventTap
- ✅ Spotify API integration (polls every 30 seconds)
- ✅ Smart text detection (exact matches, fuzzy matching, natural references)
- ✅ Automatic hyperlink insertion
- ✅ App-specific formatting (Slack, Discord, Markdown)
- ✅ Settings window with token management
- ✅ Secure keychain storage for API tokens
- ✅ Toggle on/off functionality
- ✅ Manual insert hotkey (⌘⇧L)
- ✅ Accessibility permission handling
SpotifyHyperlink/
├── AppDelegate.swift # Main app coordinator
├── MenuBarController.swift # Menu bar UI and controls
├── SpotifyClient.swift # Spotify API integration
├── KeyboardMonitor.swift # Global keyboard monitoring
├── TextMatcher.swift # Text pattern matching
├── TextReplacer.swift # Hyperlink insertion
├── SettingsWindow.swift # Settings UI
├── Info.plist # App configuration
├── SpotifyHyperlink.entitlements # Security entitlements
└── Assets.xcassets/ # App icons
See SETUP.md for complete setup and usage instructions.
open SpotifyHyperlink.xcodeprojOr build from command line:
./build.sh- Tokens from Spotify Console expire after 1 hour (for quick testing)
- For production use, implement full OAuth flow
- Requires macOS 13.0+ and Accessibility permissions
- All tokens stored securely in macOS Keychain