The Barista Logo


An i3status alternative in golang

Download sample-bar Download i3status example View on GitHub

Media Player

import ""

Show information about the currently playing track: media.New("rhythmbox"). Automatically follow the most recently connected player: media.Auto(/* exclusions */).

The name of the player should match what it uses to register its MPRIS interface with D-Bus. Use playerctl --list-all with the media player running to get the name to use here.

Not all media players register with D-Bus by default. Some require a setting to be enabled, while others may need a plugin to be installed. Searching for MPRIS or D-Bus in your player’s docs should yield instructions on how to enable D-Bus registration.

media.Auto() will use the most recently connected player, falling back to the previously connected player when it disconnects. The optional exclusions list can be used to ignore certain media players that might be misbehaving, or used for non-media purposes.




Demonstrating click handlers and multi-segment output:

func ifLeft(dofn func()) func(bar.Event) {
	return func(e bar.Event) {
		if e.Button == bar.ButtonLeft {

media.New("rhythmbox").Output(func(m media.Info) bar.Output {
	if !m.Connected() {
		return nil
	out := new(outputs.SegmentGroup)
	if m.Playing() {
	} else {
	if m.Playing() {
	return out

.OnClick(nil) in the above example prevents the default click handler of the media module from being added to part of the output.

Data: type Info struct



Note: Position() is a computed property because there are no regular updates from the media player while a track is playing. When a track begins playing, the media module tracks the rate (usually 1.0), the current time, and the current position. This provides enough information to compute the position at any point afterwards.

Because there are no regular updates while a track is playing, the media module forces its own updates every second as long as the track is playing. So if your Output function uses Position, it should work fine.

Controller Methods

In addition to the data methods listed above, media’s Info type also provides controller methods to interact with the player: