forked from slgobinath/safeeyes
-
Notifications
You must be signed in to change notification settings - Fork 0
[pull] master from slgobinath:master #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
audiblealert: add setting for volume
the __fire methods usually only fire a hook - this one does more than just that
reorders code in the order it actually gets called, and for future refactoring
splits out the parts after sleeping into a __cycle_break_countdown method so it can be later called in a callback this also switches this method from a `time.sleep()` call to using __wait_for like the rest of this module.
this refactors __wait_for to start a thread and call the passed callback after the timeout in the main thread, instead of blocking the calling thread. this makes it possible to more easily switch out the mechanism that __wait_for uses for scheduling that callback later.
this adds a __fire_hook method for safely firing an event hook on the main thread, and uses it to fire all hooks. this ensures that all hooks are always fired from the main thread in one central place. this makes changing that logic easier later this also fixes the on_count_down hook, which previously wasn't always called from the main thread. __fire_hook also ensures that plugins don't do anything weird like recursively calling methods that would trigger another hook instantly. the implementation of __fire_hook is somewhat clever. it uses a threading.Event to block on and synchronize with the event loop, so we can wait for the plugins' response and return it. since this implementation will later be replaced, it is okay that it is somewhat complicated.
again, centralize the implementation in one method so it can be more easily switched out later.
before this, the implementation is complicated and slow. it stops the scheduler completely, waits for a second, and then restarts it at the correct place. this change removes all that and replaces it with setting a _take_break_now flag and waking the scheduler. this flag is checked after every __wait_for call and, if applicable, calls the correct code. this makes taking a break using the -t cli flag or the "Take break now" option noticeably faster. it also clears up the code, making it very clear when and where a break can be taken.
instead of blocking on separate threads, use GLib timeouts to schedule the callbacks. this allows running everything on the main thread without blocking, and avoiding the need for any kind of complicated synchronization.
this is no longer needed as calling SafeEyesCore.stop() now runs synchronously on the main thread, so will complete instantly.
core: refactor to run on main thread
now that SafeEyesCore is single-threaded, this is much, much easier.
pytest: test SafeEyesCore
This uses a non-standard property on org.freedesktop.Notifications that is present on KDE Plasma.
donotdisturb: implement detection on KDE Plasma Wayland
screensaver: add tray action to lock screen now
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.3)
Can you help keep this open source service alive? 💖 Please sponsor : )