From 601a0c1611a1d8ea9def089a5a555c4bd7d6f5b9 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Fri, 13 Sep 2024 14:08:49 -0500 Subject: [PATCH] Makes the spinner configurable. --- README.md | 17 +++++++++++++++++ page_playlist.go | 9 +++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index edc5dfb..c345f53 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,9 @@ scrobble = true # Use Subsonic scrobbling for last.fm/ListenBrainz (default: fa [client] random-songs = 50 + +[ui] +spinner = '▁▂▃▄▅▆▇█▇▆▅▄▃▂▁' ``` ## Usage @@ -116,6 +119,20 @@ These controls are accessible from any view: - `d`: Delete playlist - `a`: Add playlist or song to queue +On servers with a large number of songs in the playlists, Subsonic can take a while to respond to a request for a list. stmps therefore loads playlists in the background, and will display a spinner next to the "playlist" tab label at the bottom. This spinner can be configured with the `ui.spinner` option in the config file. Some ideas are: + +```toml +spinner = '▁▂▃▄▅▆▇█▇▆▅▄▃▁' +spinner = '⠁⠂⠄⡀⢀⠠⠐⠈' +spinner = '|/-\' +spinner = '▖▘' +spinner = '▖▌▘' +spinner = '┤┘┴└├┌┬┐' +spinner = '⣾⣽⣻⢿⡿⣟⣯⣷' +``` + +The default is `▉▊▋▌▍▎▏▎▍▌▋▊▉`. Set only one of these at a time, and the glyphs must exist in the font that the terminal running stmps is using. + ## Advanced Configuration and Features ### MPRIS2 Integration diff --git a/page_playlist.go b/page_playlist.go index af960b2..bbde492 100644 --- a/page_playlist.go +++ b/page_playlist.go @@ -12,6 +12,7 @@ import ( "github.com/rivo/tview" "github.com/spezifisch/stmps/logger" "github.com/spezifisch/stmps/subsonic" + "github.com/spf13/viper" ) type PlaylistPage struct { @@ -197,7 +198,11 @@ func (p *PlaylistPage) UpdatePlaylists() { } p.isUpdating = true - var spinnerText []rune = []rune("⠁⠂⠄⡀⢀⠠⠐⠈") + var spinnerText []rune = []rune(viper.GetString("ui.spinner")) + if len(spinnerText) == 0 { + spinnerText = []rune("▉▊▋▌▍▎▏▎▍▌▋▊▉") + } + spinnerMax := len(spinnerText) - 1 playlistsButton := buttonOrder[2] stop := make(chan bool) go func() { @@ -217,7 +222,7 @@ func (p *PlaylistPage) UpdatePlaylists() { label := fmt.Sprintf(format, 3, spinnerText[idx], playlistsButton) p.ui.menuWidget.buttons[playlistsButton].SetLabel(label) idx++ - if idx > 7 { + if idx > spinnerMax { idx = 0 } })