Compare commits

...

5 Commits

Author SHA1 Message Date
adventuretc 98e6fcd9f1
Merge 6ac8b602bc into 766e9a9795 2024-02-19 08:10:36 -07:00
adventuretc 6ac8b602bc . 2024-01-27 15:32:33 +01:00
adventuretc 72eb1575d9 Fixed SafeEyes breaks not being called , (Chromium snap refuses dbus)
Fixed SafeEyes breaks not being called (crashing) when Chromium snap refuses dbus access
2024-01-19 18:37:17 +01:00
adventuretc 756e2f641d Fixed SafeEyes not being able to run on ubuntu 20.04 LTS 2024-01-19 18:35:58 +01:00
adventuretc 0e2a13110f Fixed smartpause plugin not working. 2024-01-19 18:35:26 +01:00
3 changed files with 17 additions and 7 deletions

View File

@ -55,7 +55,8 @@ def init(ctx, safeeyes_config, plugin_config):
'total_resets': 0,
}
session = context['session']['plugin'].get('healthstats', {}) | defaults
session = context['session']['plugin'].get('healthstats', {}).copy()
session.update(defaults) # refactored to maintain compatibility with python3.8 on Ubuntu 20.04 LTS (dict | dict syntax was introduced in python3.9).
if 'no_of_breaks' in session:
# Ignore old format session.
session = defaults

View File

@ -23,6 +23,7 @@ Media Control plugin lets users to pause currently playing media player from the
import logging
import os
import dbus
import dbus.exceptions
import re
import gi
from safeeyes.model import TrayAction
@ -41,11 +42,18 @@ def __active_players():
for service in bus.list_names():
if re.match('org.mpris.MediaPlayer2.', service):
player = bus.get_object(service, "/org/mpris/MediaPlayer2")
interface = dbus.Interface(player, 'org.freedesktop.DBus.Properties')
status = str(interface.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus')).lower()
if status == "playing":
players.append(player)
try:
player = bus.get_object(service, "/org/mpris/MediaPlayer2")
interface = dbus.Interface(player, 'org.freedesktop.DBus.Properties')
status = str(interface.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus')).lower()
if status == "playing":
players.append(player)
except dbus.exceptions.DBusException as e:
# Purpose of this: The Chromium snap (at least on ubuntu 20.04 LTS) forbids SafeEyes from sending dbus messages to Chromium and we must catch that exception and ignore that particular player. If we don't, the the method and plugin fails and the break itself fails to be called. With this fix, only impossible-to-reach players are ignored and all else works.
# The specific exception is (dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied)
# We don't care about logging the error but maybe we should log it in debug mode:
logging.debug(f"DBusException: {e}")
return players

View File

@ -194,7 +194,8 @@ def __start_idle_monitor():
smart_pause_activated = True
idle_start_time = datetime.datetime.now() - datetime.timedelta(seconds=system_idle_time)
logging.info('Pause Safe Eyes due to system idle')
disable_safeeyes(None, True)
info = _('Paused Safe Eyes due to system being idle')
disable_safeeyes(info, True)
elif system_idle_time < idle_time and context['state'] == State.RESTING and idle_start_time is not None:
logging.info('Resume Safe Eyes due to user activity')
smart_pause_activated = False