Repository: aome510/spotify-player (language: rust)

Issue:
Play icon always attached to {track} value
**Describe the bug**
I'd like to change a playback format so that the artists are followed by the track title. However, the playback icon is attached to a track title.

**To Reproduce**
1. Change `playback_format`:
    ```toml
    playback_format = """
    {artists} – {track}
    {album}
    {metadata}"""
    ````
2. Restart the app

**Expected behaviour**
Playback icon should be at the start of the line, before the artists.

**Actual behaviour**
Playback icon attached to the track title

![image](https://github.com/aome510/spotify-player/assets/1321838/e566ef1f-bd4a-4433-a7c0-ba07ac91efd4)


**Environment**
- OS: Windows 11
- Application version: 0.18.2

Play icon always attached to {track} value
**Describe the bug**
I'd like to change a playback format so that the artists are followed by the track title. However, the playback icon is attached to a track title.

**To Reproduce**
1. Change `playback_format`:
    ```toml
    playback_format = """
    {artists} – {track}
    {album}
    {metadata}"""
    ````
2. Restart the app

**Expected behaviour**
Playback icon should be at the start of the line, before the artists.

**Actual behaviour**
Playback icon attached to the track title

![image](https://github.com/aome510/spotify-player/assets/1321838/e566ef1f-bd4a-4433-a7c0-ba07ac91efd4)


**Environment**
- OS: Windows 11
- Application version: 0.18.2



Discussion / hints:
seems simple enough, i could take a crack at this
seems simple enough, i could take a crack at this

Fix patch:
diff --git a/docs/config.md b/docs/config.md
index 6722fc9f..d8337f9a 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -26,7 +26,7 @@ All configuration files should be placed inside the application's configuration
 | `client_id`                       | the Spotify client's ID                                                                  | `65b708073fc0480ea92a077233ca87bd`                      |
 | `client_port`                     | the port that the application's client is running on to handle CLI commands              | `8080`                                                  |
 | `tracks_playback_limit`           | the limit for the number of tracks played in a **tracks** playback                       | `50`                                                    |
-| `playback_format`                 | the format of the text in the playback's window                                          | `{track} • {artists}\n{album}\n{metadata}`              |
+| `playback_format`                 | the format of the text in the playback's window                                          | `{status} {track} • {artists}\n{album}\n{metadata}`              |
 | `notify_format`                   | the format of a notification (`notify` feature only)                                     | `{ summary = "{track} • {artists}", body = "{album}" }` |
 | `notify_timeout_in_secs`          | the timeout (in seconds) of a notification (`notify` feature only)                       | `0` (no timeout)                                        |
 | `player_event_hook_command`       | the hook command executed when there is a new player event                               | `None`                                                  |
@@ -196,6 +196,7 @@ To define application's component styles, the user can specify any of the below
 
 - `block_title`
 - `border`
+- `playback_status`
 - `playback_track`
 - `playback_artists`
 - `playback_album`
@@ -226,6 +227,7 @@ Default value for application's component styles:
 ```toml
 block_title = { fg = "Magenta"  }
 border = {}
+playback_status = { fg = "Cyan", modifiers = ["Bold"] }
 playback_track = { fg = "Cyan", modifiers = ["Bold"] }
 playback_artists = { fg = "Cyan", modifiers = ["Bold"] }
 playback_album = { fg = "Yellow" }
diff --git a/examples/app.toml b/examples/app.toml
index 76810d5e..c173df96 100644
--- a/examples/app.toml
+++ b/examples/app.toml
@@ -2,7 +2,7 @@ theme = "default"
 client_id = "65b708073fc0480ea92a077233ca87bd"
 client_port = 8080
 tracks_playback_limit = 50
-playback_format = "{track} • {artists}\n{album}\n{metadata}"
+playback_format = "{status} {track} • {artists}\n{album}\n{metadata}"
 notify_format = { summary = "{track} • {artists}", body = "{album}" }
 notify_timeout_in_secs = 0
 app_refresh_duration_in_ms = 32
diff --git a/spotify_player/src/config/mod.rs b/spotify_player/src/config/mod.rs
index 1229bfe7..074deab0 100644
--- a/spotify_player/src/config/mod.rs
+++ b/spotify_player/src/config/mod.rs
@@ -222,7 +222,7 @@ impl Default for AppConfig {
 
             tracks_playback_limit: 50,
 
-            playback_format: String::from("{track} • {artists}\n{album}\n{metadata}"),
+            playback_format: String::from("{status} {track} • {artists}\n{album}\n{metadata}"),
             #[cfg(feature = "notify")]
             notify_format: NotifyFormat {
                 summary: String::from("{track} • {artists}"),
diff --git a/spotify_player/src/config/theme.rs b/spotify_player/src/config/theme.rs
index 2004e756..f2d01332 100644
--- a/spotify_player/src/config/theme.rs
+++ b/spotify_player/src/config/theme.rs
@@ -64,6 +64,7 @@ pub struct Palette {
 pub struct ComponentStyle {
     pub block_title: Option<Style>,
     pub border: Option<Style>,
+    pub playback_status: Option<Style>,
     pub playback_track: Option<Style>,
     pub playback_artists: Option<Style>,
     pub playback_album: Option<Style>,
@@ -203,6 +204,16 @@ impl Theme {
         }
     }
 
+    pub fn playback_status(&self) -> tui::style::Style {
+        match &self.component_style.playback_status {
+            None => Style::default()
+                .fg(StyleColor::Cyan)
+                .modifiers(vec![StyleModifier::Bold])
+                .style(&self.palette),
+            Some(s) => s.style(&self.palette),
+        }
+    }
+
     pub fn playback_track(&self) -> tui::style::Style {
         match &self.component_style.playback_track {
             None => Style::default()
diff --git a/spotify_player/src/ui/playback.rs b/spotify_player/src/ui/playback.rs
index 3eae2897..9e4c4cdc 100644
--- a/spotify_player/src/ui/playback.rs
+++ b/spotify_player/src/ui/playback.rs
@@ -177,20 +177,21 @@ fn construct_playback_text(
                 playback_text.lines.push(Line::from(tmp));
                 continue;
             }
+            "{status}" => (
+                if !playback.is_playing {
+                    &configs.app_config.pause_icon
+                } else {
+                    &configs.app_config.play_icon
+                }
+                .to_owned(),
+                ui.theme.playback_status(),
+            ),
             "{track}" => (
-                format!(
-                    "{} {}",
-                    if !playback.is_playing {
-                        &configs.app_config.pause_icon
-                    } else {
-                        &configs.app_config.play_icon
-                    },
-                    if track.explicit {
-                        format!("{} (E)", track.name)
-                    } else {
-                        track.name.clone()
-                    }
-                ),
+                if track.explicit {
+                    format!("{} (E)", track.name)
+                } else {
+                    track.name.clone()
+                },
                 ui.theme.playback_track(),
             ),
             "{artists}" => (


Test patch: