mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #2276 from skligys/fix_mpris_ui_spamming
Stop MPRIS module from updating every ~20ms
This commit is contained in:
commit
265b4edb2e
@ -80,6 +80,7 @@ class Mpris : public ALabel {
|
|||||||
std::string lastPlayer;
|
std::string lastPlayer;
|
||||||
|
|
||||||
util::SleeperThread thread_;
|
util::SleeperThread thread_;
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> last_update_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace waybar::modules::mpris
|
} // namespace waybar::modules::mpris
|
||||||
|
@ -31,7 +31,8 @@ Mpris::Mpris(const std::string& id, const Json::Value& config)
|
|||||||
ellipsis_("\u2026"),
|
ellipsis_("\u2026"),
|
||||||
player_("playerctld"),
|
player_("playerctld"),
|
||||||
manager(),
|
manager(),
|
||||||
player() {
|
player(),
|
||||||
|
last_update_(std::chrono::system_clock::now() - interval_) {
|
||||||
if (config_["format-playing"].isString()) {
|
if (config_["format-playing"].isString()) {
|
||||||
format_playing_ = config_["format-playing"].asString();
|
format_playing_ = config_["format-playing"].asString();
|
||||||
}
|
}
|
||||||
@ -559,6 +560,10 @@ bool Mpris::handleToggle(GdkEventButton* const& e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto Mpris::update() -> void {
|
auto Mpris::update() -> void {
|
||||||
|
const auto now = std::chrono::system_clock::now();
|
||||||
|
if (now - last_update_ < interval_) return;
|
||||||
|
last_update_ = now;
|
||||||
|
|
||||||
auto opt = getPlayerInfo();
|
auto opt = getPlayerInfo();
|
||||||
if (!opt) {
|
if (!opt) {
|
||||||
event_box_.set_visible(false);
|
event_box_.set_visible(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user