Skip to content

Commit

Permalink
Prevent double hooks being fired on Mpris2
Browse files Browse the repository at this point in the history
  • Loading branch information
elParaguayo committed Nov 17, 2023
1 parent e64c848 commit 64c03f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
2-23-11-17: [BUGFIX] Prevent double hooks for Mpris2 widget
2023-11-13: [BUGFIX] A neater fix for the `Visualiser` CPU bug
2023-11-13: [BUGFIX] Fix `fraction` KeyError in `UpowerWidget`
2023-11-13: [FEATURE] Add `invert` option to `Visualiser` to draw bars from top down
Expand Down
11 changes: 9 additions & 2 deletions qtile_extras/widget/mpris2widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,14 @@ def __init__(self, **config):
self.add_defaults(ExtendedPopupMixin.defaults)
self.add_defaults(Mpris2.defaults)
self._popup_values = {}
self._last_meta = {}
self._last_status = ""

def get_track_info(self, metadata):
result = widget.Mpris2.get_track_info(self, metadata)
hook.fire("mpris_new_track", self.metadata)
if self.metadata != self._last_meta:
hook.fire("mpris_new_track", self.metadata)
self._last_meta = self.metadata.copy()
return result

def parse_message(self, _interface_name, changed_properties, _invalidated_properties):
Expand All @@ -139,7 +143,10 @@ def parse_message(self, _interface_name, changed_properties, _invalidated_proper
self, _interface_name, changed_properties, _invalidated_properties
)
if update_status:
hook.fire("mpris_status_change", changed_properties["PlaybackStatus"].value)
status = changed_properties["PlaybackStatus"].value
if status != self._last_status:
hook.fire("mpris_status_change", status)
self._last_status = status

def bind_callbacks(self):
self.extended_popup.bind_callbacks(
Expand Down

0 comments on commit 64c03f3

Please sign in to comment.