diff --git a/src/config.rs b/src/config.rs index e964a6c1c..cf07d05eb 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..4dd1453ee 100644 --- a/src/modules/media_player.rs +++ b/src/modules/media_player.rs @@ -236,17 +236,43 @@ 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).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!( + 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![icon(StaticIcon::MusicNote)] + 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