Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpotifyWidget for macOS

A native macOS WidgetKit widget that shows what's playing on Spotify — with album art, track info, and playback controls (play/pause, next, previous).

No Spotify API key required. Uses AppleScript to talk directly to the Spotify desktop app.

Widget sizes: small, medium, large macOS 14+ Swift 5.9


Features

  • 3 widget sizes — small, medium, large
  • Real-time updates — reacts instantly to Spotify play/pause/skip via system notifications
  • Playback controls — tap play/pause, next, previous directly from the widget
  • Album art — fetched and cached automatically
  • Menu bar app — runs silently in the background, no Dock icon
  • Auto-starts at login — registers itself as a login item on first launch
  • No API key — uses AppleScript to communicate with Spotify locally

Requirements

  • macOS 14.0 (Sonoma) or later
  • Xcode 15+ with xcodegen (brew install xcodegen)
  • Spotify desktop app installed
  • Apple Developer account (free tier works)

macOS 26 Tahoe beta note: WidgetKit has a known rendering bug (NSHostingView SIGSEGV on dealloc) that causes third-party widgets to render blank. This is an Apple bug — bug report submitted (Feedback Assistant). The widget works correctly on macOS 14/15 Sonoma/Sequoia.


Installation

One-command setup

git clone https://github.com/saikiranchepuri/SpotifyWidget.git
cd SpotifyWidget
./setup.sh

The script:

  1. Checks for xcodegen (installs via Homebrew if missing)
  2. Generates the Xcode project
  3. Builds and launches the app

Manual (Xcode)

  1. Clone the repo
  2. Run xcodegen generate
  3. Open SpotifyWidget.xcodeproj
  4. Set your Team in Signing & Capabilities for both targets
  5. Press ⌘R

Adding the widget

  1. Right-click your desktop → Edit Widgets
  2. Search "Spotify"
  3. Drag to desktop or Notification Center

Architecture

SpotifyWidget/
├── Shared/
│   ├── Constants.swift         # App Group ID, keys, URL scheme
│   └── SpotifyState.swift      # Shared data model
├── SpotifyWidgetApp/           # Main app (menu bar, no Dock icon)
│   ├── SpotifyAPI.swift        # AppleScript bridge to Spotify
│   ├── DataManager.swift       # Observes Spotify, writes to App Group
│   ├── AppDelegate.swift       # Menu bar, URL scheme handler, login item
│   └── SpotifyWidgetApp.swift  # @main entry point
└── SpotifyWidgetExtension/     # WidgetKit extension
    ├── SpotifyWidgetExtension.swift  # TimelineProvider, Widget config
    └── SpotifyWidgetView.swift       # SwiftUI views (small/medium/large)

How it works:

  1. Main app observes com.spotify.client.PlaybackStateChanged via DistributedNotificationCenter
  2. On change, reads track info via AppleScript and writes to shared UserDefaults (App Group)
  3. Calls WidgetCenter.reloadAllTimelines() to trigger widget refresh
  4. Widget extension reads from the shared UserDefaults and renders the SwiftUI view
  5. Widget buttons use spotifywidget:// URL scheme → main app handles commands via AppleScript

Privacy

  • No network requests except fetching album art from Spotify's CDN
  • No data sent anywhere — all local
  • AppleScript access to Spotify required (macOS will prompt once)

Contributing

PRs welcome. Known areas for improvement:

  • Liked/unliked song toggle
  • Progress bar / seek
  • macOS 26 Tahoe compatibility (waiting on Apple WidgetKit fix)

License

MIT — free to use, modify, and distribute.


Inspired by Spotify4BigSur

About

Native macOS WidgetKit widget for Spotify — album art, track info, and playback controls. No API key required.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages