Skip to content

feat(osd) add mpris osd for track change#2999

Merged
ItsLemmy merged 5 commits into
noctalia-dev:mainfrom
SaverinOnRails:osd-for-media-change
Jun 15, 2026
Merged

feat(osd) add mpris osd for track change#2999
ItsLemmy merged 5 commits into
noctalia-dev:mainfrom
SaverinOnRails:osd-for-media-change

Conversation

@SaverinOnRails

Copy link
Copy Markdown
Contributor

Summary

Adds an osd notification for mpris, so that it is triggered when the currently playing track is changed

Motivation

Is a neat feature to have

Aformentioned

Type of Change

  • Bug fix
  • [ *] New feature
  • Breaking change
  • Refactoring
  • Build / packaging

Related Issue

Testing

Not sure of what commands to run for tests, but it builds fine and does not break other osds.

Manual Coverage

Compositor agnostic

  • [* ] Tested on Niri
  • Tested on Hyprland
  • Tested on Sway
  • Tested on another compositor:
  • Tested with different bar positions and density settings
  • Tested at different interface scaling values
  • Tested with multiple monitors

Screenshots / Videos

Screenshot from 2026-06-12 23-09-40 Screenshot from 2026-06-12 23-09-54

Checklist

  • [* ] This PR is ready for review, or it is marked as Draft.
  • [* ] I read and followed the relevant guidance in CONTRIBUTING.md.
  • [ *] I ran just format with clang-format v22+ installed, or this PR has no code changes.
  • [ *] I ran the relevant build or test commands, or explained why they were not run.
  • [ *] I self-reviewed the changes.
  • [ *] I checked for new warnings or errors.
  • [ *] I will update end-user documentation after merge, or this PR does not change user-facing configuration or behavior.
  • [ *] I added or updated assets/translations/en.json, or this PR adds no new user-facing strings.
  • [ *] I did not edit non-English translation files unless this PR is explicitly for translation tooling, an import/export sync, or a maintainer-requested locale change.
  • [ *] I used the existing canonical names for config keys, IPC names, paths, and identifiers.

Additional Notes

Still draft because the current OSD architecture allows for one label, ideally i reckon we'd want two for the artist and track on seperate lines at least for horizontal layout. I'm still trying to understand that part of the code.

@SaverinOnRails SaverinOnRails marked this pull request as draft June 12, 2026 22:15
@SaverinOnRails

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-06-13 15-01-42

Tried to make it work with two rows but couldn't figure it out without breaking something. I've just hyphenated the artist and track.

@SaverinOnRails SaverinOnRails marked this pull request as ready for review June 13, 2026 14:11
Comment thread src/shell/osd/mpris_osd.cpp Outdated
return;
const auto activePlayer = activePlayerOpt.value();
// first artist only for now
MprisOsdData osd_data = {.Title = activePlayer.title, .Artist = activePlayer.artists[0]};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

artists[0] will crash if nor artist available in the dataset. This should use joinedArtists() for safety (even tho it maybe bring more than one artist, I think it's fine)

Naming convention violation osd_data is snake_case, it should be osdData.

Comment thread src/shell/osd/mpris_osd.h Outdated

private:
OsdOverlay* m_overlay = nullptr;
MprisOsdData lastData;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming convention violation lastData is a private member => m_lastData.

Comment thread src/shell/osd/mpris_osd.h Outdated
class OsdOverlay;

struct MprisOsdData {
std::string Title;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming convention violation, should be title and artist (no uppercase)

Comment thread src/shell/osd/mpris_osd.cpp Outdated
MprisOsdData osd_data = {.Title = activePlayer.title, .Artist = activePlayer.artists[0]};
if (osd_data == lastData)
return;
m_overlay->show(makeMprisContent(osd_data));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add aguard if (m_overlay == nullptr) return;

@ItsLemmy

Copy link
Copy Markdown
Collaborator

On a more general note, we dont want "mpris" to surface much in the front facing strings/transaltions. This is a very technical jargon that does not mean much to the regular user. I recommend to simply use "Media" or "Now playing" instead. So I would rename OsdKind::Mpris, the class name and also remove mpris from translations keys and strings.

@ItsLemmy ItsLemmy merged commit 7846a77 into noctalia-dev:main Jun 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants