Cross-platform doom-modeline segment to display information about the currently playing song. Supports both Linux (via playerctl) and macOS (via AppleScript & media-control).
You can click the status icon to toggle play/pause, or use the interactive function doom-modeline-now-playing-toggle-status
.
- Cross-platform: Works on Linux (playerctl) and macOS (AppleScript)
- Customizable: Control update interval, text length, and playerctl format
- Interactive: Click to play/pause or use keyboard commands
- Multiple players: Supports Spotify, Music.app, and any MPRIS-compatible player
- Modular: Clean provider-based architecture for easy extension
- playerctl - For MPRIS-compatible media players
# Arch Linux sudo pacman -S playerctl # Ubuntu/Debian sudo apt install playerctl # Fedora sudo dnf install playerctl
- Attempts to default to media-control
- Falls back to built-in AppleScript support (no additional dependencies)
- Supports Spotify, Music.app, and other AppleScript-compatible players or anything media-control supports
Add the package to your load path after doom-modeline
:
(add-to-list 'load-path "/path/to/doom-modeline-now-playing")
(require 'doom-modeline-now-playing)
Install doom-modeline-now-playing
with your package manager:
;; use-package
(use-package doom-modeline-now-playing
:after doom-modeline
:config
(doom-modeline-now-playing-timer))
;; straight.el
(straight-use-package 'doom-modeline-now-playing)
Add this to your config after loading doom-modeline
:
(doom-modeline-now-playing-timer)
Include now-playing
in your modeline configuration:
(doom-modeline-def-modeline 'main
'(bar workspace-name window-number modals matches buffer-info remote-host buffer-position parrot selection-info)
'(now-playing objed-state misc-info persp-name battery grip irc mu4e gnus github debug repl lsp minor-modes input-method major-mode process vcs checker))
;; Enable/disable the segment (default: t)
(setq doom-modeline-now-playing t)
;; Update interval in seconds (default: 5)
(setq doom-modeline-now-playing-interval 5)
;; Maximum text length before truncation (default: 40)
(setq doom-modeline-now-playing-max-length 40)
;; Customize output format using playerctl template syntax
(setq doom-modeline-now-playing-playerctl-format "{{artist}} - {{title}}")
;; Ignore specific players (e.g., browser players)
(setq doom-modeline-now-playing-playerctl-ignored-players '("firefox" "chromium"))
Available playerctl format options:
playerName
- Player application nameartist
- Track artisttitle
- Track titlealbum
- Album namestatus
- Playback status (playing/paused/stopped)position
- Current position in microsecondsvolume
- Volume level
Functions: lc()
, uc()
, duration()
, markup_escape()
, default()
, emoji()
;; Specify which applications to check (default: Spotify and Music)
(setq doom-modeline-now-playing-macos-players '("Spotify" "Music" "VLC"))
;; Toggle play/pause for current player
M-x doom-modeline-now-playing-toggle-status
;; Start/stop the update timer
M-x doom-modeline-now-playing-timer
The package uses a modular provider-based architecture:
doom-modeline-now-playing.el
- Core functionality and UIdoom-modeline-now-playing-playerctl.el
- Linux/playerctl providerdoom-modeline-now-playing-osascript.el
- macOS/AppleScript providerdoom-modeline-now-playing-media-control.el
- media-control provider
The appropriate provider is automatically loaded based on your system type.
- Ensure a supported media player is running
- Check
doom-modeline-now-playing-playerctl-ignored-players
settings - Test playerctl directly:
playerctl status
- Verify the media player supports AppleScript
- Add unsupported players to
doom-modeline-now-playing-macos-players
Contributions welcome! To add support for new platforms:
- Create a new provider file following the existing pattern
- Inherit from
doom-modeline-now-playing-provider
- Implement
doom-modeline-now-playing-provider-get-info
anddoom-modeline-now-playing-provider-play-pause
- Add loading logic to the main file