Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ Requires Go 1.26+ and a reachable MPD server.
./mpdtui -mini # lightweight inline player
./mpdtui -p # fuzzy-search playlists; Enter clears the queue and plays it
./mpdtui -t # fuzzy-search tracks; Enter adds it to the queue and plays it
./mpdtui -v # print version and exit
```

`-mini`, `-p`, and `-t` are mutually exclusive.
`-mini`, `-p`, `-t`, and `-lyrics-line` are mutually exclusive.

Connects using the same environment variables as `mpc`:

Expand Down
7 changes: 7 additions & 0 deletions cmd/mpdtui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@ import (
"mpdtui/internal/mpdclient"
"mpdtui/internal/picker"
"mpdtui/internal/ui"
"mpdtui/internal/version"
)

func main() {
showVersion := flag.Bool("v", false, "print version and exit")
miniMode := flag.Bool("mini", false, "run the lightweight inline player instead of the full panel UI")
playlistPicker := flag.Bool("p", false, "fuzzy-search playlists; Enter clears the queue and plays the selection")
trackPicker := flag.Bool("t", false, "fuzzy-search tracks; Enter adds the selection to the queue and plays it")
lyricsLine := flag.Bool("lyrics-line", false, "print the current synced (.lrc) lyrics window (1 line above, the current line, 2 lines below) and exit -- for embedding in an external tool like conky")
flag.Parse()

if *showVersion {
fmt.Println(version.String)
return
}

if modeCount(*miniMode, *playlistPicker, *trackPicker, *lyricsLine) > 1 {
fmt.Fprintln(os.Stderr, "mpdtui: -mini, -p, -t, and -lyrics-line are mutually exclusive")
os.Exit(1)
Expand Down
1 change: 1 addition & 0 deletions internal/ui/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
func newTestApp() *App {
a := &App{tv: tview.NewApplication()}
a.build()
a.queue.table.SetRect(0, 0, 150, 40)
return a
}

Expand Down
10 changes: 8 additions & 2 deletions internal/ui/lyrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,14 @@ func resolveLyricsViewerColumnBounds(qx, qw, yearX, durationX int) (int, int) {
// layout, not a stale one.
func (v *lyricsViewer) positionOverQueueColumns() {
qx, qy, qw, qh := v.app.queue.table.GetRect()
cols := newQueueColumns(v.app.musicDir != "", v.app.metaDB != nil)
yearX, _, _ := v.app.queue.table.GetCell(0, cols.year).GetLastPosition()
cols := v.app.queue.cols
var yearX int
if cols.year >= 0 {
yearX, _, _ = v.app.queue.table.GetCell(0, cols.year).GetLastPosition()
} else {
// In compact mode (no Year column), position lyrics viewer over the right 50% of the Queue table.
yearX = qx + qw/2
}
durationX, _, _ := v.app.queue.table.GetCell(0, cols.duration).GetLastPosition()
yearX, durationX = resolveLyricsViewerColumnBounds(qx, qw, yearX, durationX)
v.SetRect(lyricsViewerRect(qy, qh, yearX, durationX))
Expand Down
Loading