Add track_format config option (#800)

* Added track_name_first config option to allow choosing if artists' names should be shown before or after the track name.

* Added active_fields config option, which allows configuration of which columns are visible in Queue/Library view.
This also removes the need for a separate track_name_first and album_column option.

* Fixed README

* Made custom tracklist formatting more flexible.
Updated readme with new instructions.
Reformatted impl member order to match the definitions in traits.rs.

* Added track_name_first config option to allow choosing if artists' names should be shown before or after the track name.

* Added active_fields config option, which allows configuration of which columns are visible in Queue/Library view.
This also removes the need for a separate track_name_first and album_column option.

* Fixed README

* Made custom tracklist formatting more flexible.
Updated readme with new instructions.
Reformatted impl member order to match the definitions in traits.rs.

* Fetch formatting config from library config

Instead of the lazy static mutex

* Moved custom format function to Playable impl as it's a better location to handle both Tracks and Episodes

* Rename from `tracklist_formatting` to `track_format`

Also shorten `format_{left|center|right}` to `{left|center|right}`

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
This commit is contained in:
Bettehem
2022-05-28 15:12:04 +03:00
committed by Henrik Friedrichsen
parent 0e50466a5e
commit f7450321da
12 changed files with 273 additions and 110 deletions

View File

@@ -46,6 +46,7 @@ as the \*BSDs.
- [Custom Keybindings](#custom-keybindings)
- [Proxy](#proxy)
- [Theming](#theming)
- [Track Formatting](#track-formatting)
- [Cover Drawing](#cover-drawing)
- [Authentication](#authentication)
@@ -328,6 +329,7 @@ Possible configuration values are:
| `repeat` | Set default repeat mode | `off`, `track`, `playlist` | `off` |
| `playback_state` | Set default playback state | `"Stopped"`, `"Paused"`, `"Playing"`, `"Default"` | `"Paused"` |
| `library_tabs` | Tabs to show in library screen | Array of `tracks`, `albums`, `artists`, `playlists`, `podcasts` | All tabs |
| `[track_format]` | Set active fields shown in Library/Queue views | See [track formatting](#track-formatting) | |
| `[theme]` | Custom theme | See [custom theme](#theming) | |
| `[keybindings]` | Custom keybindings | See [custom keybindings](#custom-keybindings) | |
@@ -385,6 +387,65 @@ search_match = "light red"
More examples can be found in [this pull request](https://github.com/hrkfdn/ncspot/pull/40).
### Track Formatting
It's possible to customize which fields are shown in Queue/Library views.
If you don't define `center` for example, the default value will be used.
Available options for tracks:
`%artists`, `%title`, `%album`, `%saved`, `%duration`
Default configuration:
```toml
[track_format]
left = "%artists - %title"
center = "%album"
right = "%saved %duration"
```
<details><summary>Examples: (Click to show/hide)</summary>
Example 1 - Show only album name and track name after it:
```toml
[track_format]
left = "%album"
center = "%title"
right = ""
```
Example 2 - Show track title before artists, and don't show album at all:
```toml
[track_format]
left = "%title - %artists"
center = ""
```
Example 3 - Show everything as default, but hide saved status and track length:
```toml
[track_format]
right = ""
```
Example 4 - Show everything as default, except show title before artists:
```toml
[track_format]
left = "%title - %artists"
```
Example 5 - Show saved status and duration first, followed by track title and artists, with the album last:
```toml
[track_format]
left = "|%saved| %duration | %title - %artists"
center = ""
right = "%album"
```
</details>
## Cover Drawing
When compiled with the `cover` feature, `ncspot` can draw the album art of the