mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
commit
d5fa20dd33
@ -144,7 +144,7 @@ void waybar::modules::MPD::setLabel() {
|
||||
bool singleActivated = mpd_status_get_single(status_.get());
|
||||
std::string singleIcon = getOptionIcon("single", singleActivated);
|
||||
|
||||
// TODO: format can fail
|
||||
try {
|
||||
label_.set_markup(
|
||||
fmt::format(format,
|
||||
fmt::arg("artist", Glib::Markup::escape_text(artist).raw()),
|
||||
@ -161,17 +161,23 @@ void waybar::modules::MPD::setLabel() {
|
||||
fmt::arg("randomIcon", randomIcon),
|
||||
fmt::arg("repeatIcon", repeatIcon),
|
||||
fmt::arg("singleIcon", singleIcon)));
|
||||
} catch (fmt::format_error const& e) {
|
||||
spdlog::warn("mpd: format error: {}", e.what());
|
||||
}
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
std::string tooltip_format;
|
||||
tooltip_format = config_["tooltip-format"].isString() ? config_["tooltip-format"].asString()
|
||||
: "MPD (connected)";
|
||||
try {
|
||||
auto tooltip_text = fmt::format(tooltip_format,
|
||||
fmt::arg("artist", artist),
|
||||
fmt::arg("albumArtist", album_artist),
|
||||
fmt::arg("album", album),
|
||||
fmt::arg("title", title),
|
||||
fmt::arg("date", date),
|
||||
fmt::arg("elapsedTime", elapsedTime),
|
||||
fmt::arg("totalTime", totalTime),
|
||||
fmt::arg("songPosition", song_pos),
|
||||
fmt::arg("queueLength", queue_length),
|
||||
fmt::arg("stateIcon", stateIcon),
|
||||
@ -180,6 +186,9 @@ void waybar::modules::MPD::setLabel() {
|
||||
fmt::arg("repeatIcon", repeatIcon),
|
||||
fmt::arg("singleIcon", singleIcon));
|
||||
label_.set_tooltip_text(tooltip_text);
|
||||
} catch (fmt::format_error const& e) {
|
||||
spdlog::warn("mpd: format error (tooltip): {}", e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,8 +278,9 @@ void waybar::modules::MPD::checkErrors(mpd_connection* conn) {
|
||||
default:
|
||||
if (conn) {
|
||||
auto error_message = mpd_connection_get_error_message(conn);
|
||||
std::string error(error_message);
|
||||
mpd_connection_clear_error(conn);
|
||||
throw std::runtime_error(std::string(error_message));
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
throw std::runtime_error("Invalid connection");
|
||||
}
|
||||
|
@ -341,6 +341,7 @@ void Disconnected::disarm_timer() noexcept {
|
||||
}
|
||||
|
||||
void Disconnected::entry() noexcept {
|
||||
ctx_->emit();
|
||||
arm_timer(1'000);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user