Skip to content
Open
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
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ pub enum MediaPlayerFormat {
Icon,
#[default]
IconAndTitle,
Cover,
CoverAndTitle,
}

#[derive(Deserialize, Clone, Debug)]
Expand Down
46 changes: 36 additions & 10 deletions src/modules/media_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions website/docs/configuration/modules/media_player.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down