seek

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use: "seek",
	Example: `
  waybar-lyric seek 20s # Seeks 20 seconds ahead
  waybar-lyric seek --lyric 1 # Seeks to next lyric line
  waybar-lyric seek -- -10s # Go back 10 seconds
  waybar-lyric seek -- 20% # Seek 20% of total length forward
  `,
	Short: "Seek player position",
	Args:  cobra.ExactArgs(1),

	DisableFlagsInUseLine: true,
	RunE: func(cmd *cobra.Command, args []string) error {
		conn, err := dbus.SessionBus()
		if err != nil {
			return fmt.Errorf("failed to create dbus connection: %w", err)
		}
		slog.Debug("Created dbus session bus")

		mp, err := player.Select(conn)
		if err != nil {
			return fmt.Errorf("failed to select player: %w", err)
		}
		slog.Debug("Selected player", "player", mp.GetName())

		input := args[0]

		if strings.HasSuffix(input, "%") {
			length, err := mp.GetLength()
			if err != nil {
				return fmt.Errorf("failed to get song duration: %v", err)
			}
			return seekPercentOffset(mp, input, length)
		}

		if !lyricsLine {
			return seekExactOffset(mp, input)
		}

		info, err := player.Parse(mp)
		if err != nil {
			return fmt.Errorf("failed to parse player information: %w", err)
		}

		slog.Debug(
			"Parsed player information",
			"title", info.Title,
			"artist", info.Artist,
		)

		lyrics, err := lyric.GetLyrics(cmd.Context(), info)
		if err != nil {
			return fmt.Errorf("failed to fetch lyrics: %w", err)
		}

		slog.Debug("Fetched lyrics", "line-count", len(lyrics.Lines))

		return seekLyricLine(mp, info, lyrics.Lines, input)
	},
}

Command is the position seeker 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