mpris

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mpris is a bar module that talks to MPRIS2-compatible media players over D-Bus (session bus) and shows the currently playing track plus prev/play-pause/next controls.

Player selection strategy: prefer a player whose PlaybackStatus is "Playing"; if none is playing, fall back to the first connected one (so paused tracks still show with their controls). When the user configures a priority list, walk it in order; otherwise sort the connected players alphabetically by bus name for stability.

Index

Constants

This section is empty.

Variables

View Source
var DefaultIcons = Icons{
	Music: "",
	Prev:  "",
	Next:  "",
	Play:  "",
	Pause: "",
}

DefaultIcons is the Nerd Font codepoint set used when the caller doesn't override MPRIS.Icons.

Functions

This section is empty.

Types

type Icons

type Icons struct {
	Music string
	Prev  string
	Next  string
	Play  string
	Pause string
}

Icons groups the per-state media glyphs. New initialises Icons to the Nerd Font DefaultIcons below; callers can override the field directly to change individual glyphs.

type MPRIS

type MPRIS struct {
	Interval     time.Duration
	FG           color.RGBA
	BG           color.RGBA
	MaxTitleRune int      // max characters of "Artist – Title" (0 = no limit)
	Players      []string // optional priority list of player short-names (e.g. "spotify", "mpv")
	Icons        Icons
	// contains filtered or unexported fields
}

MPRIS polls the session D-Bus for active MPRIS2 players and renders title + transport controls for the preferred one.

func New

func New(interval time.Duration, fg, bg color.RGBA) *MPRIS

New builds an MPRIS module. interval defaults to 1s. maxTitleRune defaults to 30 if zero.

func (*MPRIS) HoverText

func (m *MPRIS) HoverText() string

HoverText returns the untruncated "Artist – Title" of the currently selected player for the tooltip popup. Empty when the module is hidden (no track playing). Implements module.Hoverable.

func (*MPRIS) Name

func (m *MPRIS) Name() string

func (*MPRIS) OnClick

func (m *MPRIS) OnClick(clickID string, button uint32)

func (*MPRIS) Render

func (m *MPRIS) Render() []module.Segment

func (*MPRIS) Start

func (m *MPRIS) Start(ctx context.Context) <-chan struct{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL