playpause

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:          "play-pause",
	Short:        "Toggle play-pause state",
	SilenceUsage: true,

	DisableFlagParsing: true,
	RunE: func(_ *cobra.Command, _ []string) error {
		conn, err := dbus.SessionBus()
		if err != nil {
			slog.Error("Failed to create dbus connection", "error", err)
			return err
		}

		var mp *mpris.Player
		for mp == nil {
			p, err := player.Select(conn)
			if err == nil {
				slog.Debug("Failed to select player", "error", err)
				mp = p
			}
		}
		slog.Debug("Player selected", "player", mp)

		slog.Info("Toggling player state")
		if err := mp.PlayPause(); err != nil {
			slog.Error("Failed to toggle player state", "error", err)
			return err
		}
		return nil
	},
}

Command is the play-pause command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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