Commit 6349949
committed
fix: fail safely if unable to get player status (Media Control)
In come cases where there exists a registered MPRIS player but that
doesn't have support for playerstatus, safeeyes errors and doesnt go
launch a break when the Media Control plugin is enabled.
This patch adds a check too the mediacontrol plugin such that it checks
if "PlaybackStatus" cached_property is not None, and only then attempts
to get media playing status.
Steps to reproduce:
1. Install playerctl
2. Launch playerctld
3. Do not play any media (close all media playing apps)
4. Try to launch a break using safeeyes
Error:
```
File "/usr/lib/python3.13/site-packages/safeeyes/utility.py", line 106, in <lambda>
GLib.idle_add(lambda: target_function(*args, **kwargs))
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/safeeyes/core.py", line 277, in __fire_start_break
self.start_break.fire(break_obj)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/safeeyes/model.py", line 293, in fire
if not handler(*args, **keywargs):
~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/safeeyes/safeeyes.py", line 356, in start_break
actions = self.plugins_manager.get_break_screen_tray_actions(break_obj)
File "/usr/lib/python3.13/site-packages/safeeyes/plugin_manager.py", line 209, in get_break_screen_tray_actions
action = plugin['module'].get_tray_action(break_obj)
File "/usr/lib/python3.13/site-packages/safeeyes/plugins/mediacontrol/plugin.py", line 89, in get_tray_action
players = __active_players()
File "/usr/lib/python3.13/site-packages/safeeyes/plugins/mediacontrol/plugin.py", line 62, in __active_players
status = player.get_cached_property('PlaybackStatus').unpack().lower()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'unpack'
```
Expected Behaviour:
Doesn't crash1 parent 6061843 commit 6349949
1 file changed
+9
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
63 | 71 | | |
64 | | - | |
65 | | - | |
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| |||
0 commit comments