From 53a71613a2a4300218845a8719c6fb653feb5099 Mon Sep 17 00:00:00 2001 From: Luca Date: Wed, 13 May 2026 16:39:31 +0200 Subject: [PATCH 1/2] added cover art to toolbar --- src/config.rs | 2 ++ src/modules/media_player.rs | 30 +++++++++++++++++-- .../configuration/modules/media_player.md | 14 +++++---- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/config.rs b/src/config.rs index e964a6c1c..3dfd03ddc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -627,6 +627,8 @@ pub enum MediaPlayerFormat { Icon, #[default] IconAndTitle, + Cover, + CoverAndTitle } #[derive(Deserialize, Clone, Debug)] diff --git a/src/modules/media_player.rs b/src/modules/media_player.rs index 4add80480..b136764e9 100644 --- a/src/modules/media_player.rs +++ b/src/modules/media_player.rs @@ -237,7 +237,8 @@ impl MediaPlayer { self.service.as_ref().and_then(|s| { s.players().first().map(|player| { let title = - (self.config.indicator_format == MediaPlayerFormat::IconAndTitle).then(|| { + (self.config.indicator_format == MediaPlayerFormat::IconAndTitle + || self.config.indicator_format == MediaPlayerFormat::CoverAndTitle).then(|| { container( text(self.get_title(player)) .wrapping(text::Wrapping::None) @@ -246,7 +247,32 @@ impl MediaPlayer { .clip(true) }); - row![icon(StaticIcon::MusicNote)] + + let cover : Element<'_, _> = if matches!( + self.config.indicator_format, + MediaPlayerFormat::Cover | MediaPlayerFormat::CoverAndTitle + ) { + let img = player + .metadata + .as_ref() + .and_then(|m| m.art_url.as_ref()) + .and_then(|url| s.get_cover(url)); + + match img { + Some(handle) => container( + image(handle) + .filter_method(image::FilterMethod::Linear), + ) + .padding([space.xxs / 2.0, 0.0]) + .into(), + + None => icon(StaticIcon::MusicNote).into(), + } + } else { + icon(StaticIcon::MusicNote).into() + }; + + row![cover] .push(title) .align_y(Vertical::Center) .spacing(space.xs) diff --git a/website/docs/configuration/modules/media_player.md b/website/docs/configuration/modules/media_player.md index 03f261498..3d7cc5089 100644 --- a/website/docs/configuration/modules/media_player.md +++ b/website/docs/configuration/modules/media_player.md @@ -14,12 +14,14 @@ using the `max_title_length` field (default: `100`). The tray indicator can show either the media icon alone or the icon together with the current title. Configure this with the `indicator_format` field: -| Value | Description | -| -------------- | ---------------------------------------------------------- | -| `Icon` | Displays only the media icon in the status bar. | -| `IconAndTitle` | Displays the icon followed by the current title (default). | - -Use `Icon` if you want a compact indicator or have limited space. +| Value | Description | +| -------------- | ------------------------------------------------------------------------------------------------------------ | +| `Icon` | Displays only the media icon in the status bar. | +| `IconAndTitle` | Displays the icon followed by the current title (default). | +| `Cover` | Displays cover art when available; otherwise falls back to the media icon. | +| `CoverAndTitle`| Displays cover art followed by the current title; if cover art is unavailable, falls back to icon and title. | + +Use `Icon` or `Cover` if you want a compact indicator or have limited space. ## Menu From a2daec8c6b2710c8262198fb5f7d8685a9165d11 Mon Sep 17 00:00:00 2001 From: Luca Date: Wed, 13 May 2026 16:51:43 +0200 Subject: [PATCH 2/2] ran make check --- src/config.rs | 2 +- src/modules/media_player.rs | 38 ++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/config.rs b/src/config.rs index 3dfd03ddc..cf07d05eb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -628,7 +628,7 @@ pub enum MediaPlayerFormat { #[default] IconAndTitle, Cover, - CoverAndTitle + CoverAndTitle, } #[derive(Deserialize, Clone, Debug)] diff --git a/src/modules/media_player.rs b/src/modules/media_player.rs index b136764e9..4dd1453ee 100644 --- a/src/modules/media_player.rs +++ b/src/modules/media_player.rs @@ -236,19 +236,20 @@ impl MediaPlayer { let (space, font_size) = use_theme(|theme| (theme.space, theme.font_size)); self.service.as_ref().and_then(|s| { s.players().first().map(|player| { - let title = - (self.config.indicator_format == MediaPlayerFormat::IconAndTitle - || self.config.indicator_format == MediaPlayerFormat::CoverAndTitle).then(|| { - container( - text(self.get_title(player)) - .wrapping(text::Wrapping::None) - .size(font_size.sm), - ) - .clip(true) - }); - + let title = matches!( + self.config.indicator_format, + MediaPlayerFormat::IconAndTitle | MediaPlayerFormat::CoverAndTitle + ) + .then(|| { + container( + text(self.get_title(player)) + .wrapping(text::Wrapping::None) + .size(font_size.sm), + ) + .clip(true) + }); - let cover : Element<'_, _> = if matches!( + let cover: Element<'_, _> = if matches!( self.config.indicator_format, MediaPlayerFormat::Cover | MediaPlayerFormat::CoverAndTitle ) { @@ -259,19 +260,18 @@ impl MediaPlayer { .and_then(|url| s.get_cover(url)); match img { - Some(handle) => container( - image(handle) - .filter_method(image::FilterMethod::Linear), - ) - .padding([space.xxs / 2.0, 0.0]) - .into(), + Some(handle) => { + container(image(handle).filter_method(image::FilterMethod::Linear)) + .padding([space.xxs / 2.0, 0.0]) + .into() + } None => icon(StaticIcon::MusicNote).into(), } } else { icon(StaticIcon::MusicNote).into() }; - + row![cover] .push(title) .align_y(Vertical::Center)