Skip to content

mpris: set xesam:url tag - #1439

Closed
LunaPresent wants to merge 1 commit into
cmus:masterfrom
LunaPresent:master
Closed

LunaPresent wants to merge 1 commit into
cmus:masterfrom
LunaPresent:master

Conversation

@LunaPresent

Copy link
Copy Markdown

This PR makes cmus set the xesam:url tag as described in the mpris spec. This makes it easier for external scripts and applications to interact with the currently playing song, e.g. finding the matching .lrc file.

Comment thread mpris.c
Comment on lines +436 to +441
const char prefix[] = "file://";
char corrected[sizeof(prefix) - 1 + u_str_print_size(ti->filename)];
memcpy(corrected, prefix, sizeof(prefix) - 1);
u_to_utf8(corrected + sizeof(prefix) - 1, ti->filename);
CK(mpris_msg_append_sas_dict(reply,
"xesam:url", corrected));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe this needs URL escaping (except for slashes). It's not clear based on the MPRIS spec, but at least GLib and browsers will parse/strip query strings and fragments.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, it definitely needs URL escaping; playerctl and KDE depend on it, and most other players escape it too.

@pgaskin pgaskin mentioned this pull request Jan 10, 2026

@pgaskin pgaskin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I checked some other MPRIS implementations and added a few comments.

In addition, we should use the original string and not do additional normalization before encoding it.

Also, this doesn't handle cdda and cue URLs, but tha can be done separately.

Comment thread mpris.c
Comment on lines +436 to +441
const char prefix[] = "file://";
char corrected[sizeof(prefix) - 1 + u_str_print_size(ti->filename)];
memcpy(corrected, prefix, sizeof(prefix) - 1);
u_to_utf8(corrected + sizeof(prefix) - 1, ti->filename);
CK(mpris_msg_append_sas_dict(reply,
"xesam:url", corrected));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, it definitely needs URL escaping; playerctl and KDE depend on it, and most other players escape it too.

Comment thread mpris.c
char corrected[sizeof(prefix) - 1 + u_str_print_size(ti->filename)];
memcpy(corrected, prefix, sizeof(prefix) - 1);
u_to_utf8(corrected + sizeof(prefix) - 1, ti->filename);
CK(mpris_msg_append_sas_dict(reply,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be ss, not sas.

@pgaskin

pgaskin commented Sep 24, 2026

Copy link
Copy Markdown
Member

I am going to reimplement this from scratch myself.

@pgaskin pgaskin closed this Sep 24, 2026
@pgaskin pgaskin mentioned this pull request Sep 24, 2026
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