A clean Spotify integration for niri that gives you a floating, toggle-able Spotify window controlled from waybar.
- Click "Spotify" in waybar to show/hide the window
- Spotify opens as a floating window in the top-right corner
- Window remembers its position if you drag it
- Track info shows in waybar with play/pause, next, previous controls
- Hidden Spotify moves to workspace 9 (out of the way but keeps playing)
Add this to your window rules section:
// Spotify as floating window (top-right)
window-rule {
match app-id="Spotify"
open-floating true
default-column-width { fixed 700; }
default-window-height { fixed 500; }
default-floating-position x=32 y=32 relative-to="top-right"
}Add these modules to your modules-right:
"modules-right": ["custom/spotify-app", "custom/spotify-track", ...]And add the module definitions:
"custom/spotify-app": {
"format": " {}",
"exec": "echo Spotify",
"interval": 60,
"on-click": "~/.config/waybar/scripts/spotify-toggle.sh"
},
"custom/spotify-track": {
"format": "{}",
"max-length": 35,
"interval": 1,
"exec": "~/.config/waybar/scripts/spotify-track.sh",
"on-click": "playerctl -p spotify play-pause",
"on-click-right": "playerctl -p spotify next",
"on-click-middle": "playerctl -p spotify previous"
}#!/bin/bash
spotify_info=$(niri msg --json windows | jq -r '.[] | select(.app_id == "Spotify")')
spotify_id=$(echo "$spotify_info" | jq -r '.id // empty')
is_focused=$(echo "$spotify_info" | jq -r '.is_focused // false')
if [ -z "$spotify_id" ]; then
# Launch Spotify
spotify &
elif [ "$is_focused" = "true" ]; then
# Spotify is focused, hide it to workspace 9
niri msg action move-window-to-workspace --window-id "$spotify_id" --focus false 9
else
# Bring it back to workspace 1 and focus
niri msg action move-window-to-workspace --window-id "$spotify_id" 1
niri msg action focus-window --id "$spotify_id"
fi#!/bin/bash
player_status=$(playerctl -p spotify status 2>/dev/null)
if [ "$player_status" = "Playing" ]; then
echo "$(playerctl -p spotify metadata artist 2>/dev/null) - $(playerctl -p spotify metadata title 2>/dev/null)"
elif [ "$player_status" = "Paused" ]; then
echo "$(playerctl -p spotify metadata artist 2>/dev/null) - $(playerctl -p spotify metadata title 2>/dev/null)"
else
echo ""
fisudo apt install playerctl jq| Action | Result |
|---|---|
| Click " Spotify" | Toggle window visibility (launch if not running) |
| Click track name | Play/pause |
| Right-click track | Next track |
| Middle-click track | Previous track |
- Requires niri v25.01+ for
default-floating-position - Spotify hides to workspace 9 when toggled off
- Window position persists after dragging