Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpd: add uri and filename format arguments #3849

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions man/waybar-mpd.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ Addressed by *mpd*

*{queueLength}*: The length of the current queue.

*{uri}*: The URI of the song relative to the MPD music directory.

*{filename}* The last part of the URI.

*{stateIcon}*: The icon corresponding to the playing or paused status of the player (see *state-icons* option)

*{consumeIcon}*: The icon corresponding the "consume" option (see *consume-icons* option)
Expand Down
9 changes: 6 additions & 3 deletions src/modules/mpd/mpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void waybar::modules::MPD::setLabel() {

auto format = format_;
Glib::ustring artist, album_artist, album, title;
std::string date, filename;
std::string date, filename, uri;
int song_pos = 0, queue_length = 0, volume = 0;
std::chrono::seconds elapsedTime, totalTime;

Expand Down Expand Up @@ -151,6 +151,7 @@ void waybar::modules::MPD::setLabel() {
title = sanitize_string(getTag(MPD_TAG_TITLE));
date = sanitize_string(getTag(MPD_TAG_DATE));
filename = sanitize_string(getFilename());
uri = mpd_song_get_uri(song_.get());
song_pos = mpd_status_get_song_pos(status_.get()) + 1;
volume = mpd_status_get_volume(status_.get());
if (volume < 0) {
Expand Down Expand Up @@ -184,7 +185,8 @@ void waybar::modules::MPD::setLabel() {
fmt::arg("songPosition", song_pos), fmt::arg("queueLength", queue_length),
fmt::arg("stateIcon", stateIcon), fmt::arg("consumeIcon", consumeIcon),
fmt::arg("randomIcon", randomIcon), fmt::arg("repeatIcon", repeatIcon),
fmt::arg("singleIcon", singleIcon), fmt::arg("filename", filename));
fmt::arg("singleIcon", singleIcon), fmt::arg("filename", filename),
fmt::arg("uri", uri));
if (text.empty()) {
label_.hide();
} else {
Expand All @@ -208,7 +210,8 @@ void waybar::modules::MPD::setLabel() {
fmt::arg("totalTime", totalTime), fmt::arg("songPosition", song_pos),
fmt::arg("queueLength", queue_length), fmt::arg("stateIcon", stateIcon),
fmt::arg("consumeIcon", consumeIcon), fmt::arg("randomIcon", randomIcon),
fmt::arg("repeatIcon", repeatIcon), fmt::arg("singleIcon", singleIcon));
fmt::arg("repeatIcon", repeatIcon), fmt::arg("singleIcon", singleIcon),
fmt::arg("filename", filename), fmt::arg("uri", uri));
label_.set_tooltip_text(tooltip_text);
} catch (fmt::format_error const& e) {
spdlog::warn("mpd: format error (tooltip): {}", e.what());
Expand Down