diff --git a/config/config.go b/config/config.go index b7ef697..fe62509 100644 --- a/config/config.go +++ b/config/config.go @@ -34,10 +34,11 @@ func init() { } type Config struct { - Player string `default:"spotify" yaml:"player"` - IgnoreErrors bool `default:"true" yaml:"ignoreErrors"` - TimerInterval int `default:"200" yaml:"timerInterval"` - UpdateInterval int `default:"2000" yaml:"updateInterval"` + Player string `default:"spotify" yaml:"player"` + IgnoreErrors bool `default:"true" yaml:"ignoreErrors"` + ShowLyricsNotFound bool `default:"true" yaml:"showLyricsNotFound"` + TimerInterval int `default:"200" yaml:"timerInterval"` + UpdateInterval int `default:"2000" yaml:"updateInterval"` Style struct { HAlignment string `default:"center" yaml:"hAlignment"` diff --git a/lyrics/lyrics.go b/lyrics/lyrics.go index dba7cae..443adfa 100644 --- a/lyrics/lyrics.go +++ b/lyrics/lyrics.go @@ -5,6 +5,8 @@ import ( "strings" ) +const NoLyricsPlaceholder = "Hmm. We don't know the lyrics for this one." + type Provider interface { Lyrics(artist, track string) ([]Line, error) } diff --git a/ui/ui.go b/ui/ui.go index a94ba07..96a1751 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -79,7 +79,7 @@ func (m *Model) Update(message tea.Msg) (tea.Model, tea.Cmd) { } case "up": - if m.state.Playing && lyrics.Timesynced(m.state.Lines) { + if len(m.state.Lines) == 0 || (m.state.Playing && lyrics.Timesynced(m.state.Lines)) { break } m.state.Index -= 1 @@ -87,7 +87,7 @@ func (m *Model) Update(message tea.Msg) (tea.Model, tea.Cmd) { m.state.Index = 0 } case "down": - if m.state.Playing && lyrics.Timesynced(m.state.Lines) { + if len(m.state.Lines) == 0 || (m.state.Playing && lyrics.Timesynced(m.state.Lines)) { break } m.state.Index += 1 @@ -113,6 +113,15 @@ func (m *Model) View() string { ) } if len(m.state.Lines) == 0 { + if m.Config.ShowLyricsNotFound { + return gloss.PlaceVertical( + m.h, gloss.Center, + m.styleCurrent. + Align(gloss.Center). + Width(m.w). + Render(lyrics.NoLyricsPlaceholder), + ) + } return "" }