Skip to content

Commit

Permalink
Makes the spinner configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxserxxx committed Sep 13, 2024
1 parent b203a16 commit 601a0c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ scrobble = true # Use Subsonic scrobbling for last.fm/ListenBrainz (default: fa

[client]
random-songs = 50

[ui]
spinner = '▁▂▃▄▅▆▇█▇▆▅▄▃▂▁'
```

## Usage
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions page_playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand All @@ -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
}
})
Expand Down

0 comments on commit 601a0c1

Please sign in to comment.