Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added {status} for customizing play/pause location/style, resolves #487 #491

Merged
merged 3 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion examples/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spotify_player/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
Expand Down
11 changes: 11 additions & 0 deletions spotify_player/src/config/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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()
Expand Down
27 changes: 14 additions & 13 deletions spotify_player/src/ui/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}" => (
Expand Down
Loading