-
Notifications
You must be signed in to change notification settings - Fork 19
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
Implement listener
for macOS
#25
Comments
I invested some time into trying to implement this, but so far I had lo luck. If anyone is willing to pick up this task, further information on the most severe issues can be found here: https://stackoverflow.com/questions/72982210/swift-and-python-get-a-runloop-that-can-run-in-threading and here: https://developer.apple.com/forums/thread/710135?login=true&page=1&r_s_legacy=true#720551022 I pushed the library implementations that I tried in the macos_listener_attempts branch, but none of them is functional from a secondary thread (a fundamental requirement for this package). |
Is there a reason something akin to this would not work? def listener(callback):
old = isDark()
while True:
x = isDark()
if x != old:
old = x
callback(x)
time.sleep(.01)
def listen(callback):
threading.Thread(target=listener, args=(callback,)).start() This seemed to work for me, though maybe you'd want I realize this might not be an ideal listener, but given the current lack of any, might this be acceptable in the meantime? |
A PR of the above: #27 |
@zwimer Thanks for your contribution. I apologize if I did not reply sooner, but I think this approach is not truly viable. This thread will constantly call Therefore, I would be against integrating this in the As you mentioned, though, as a last resort measure any developer can implement a similar approach in their own codebase, where they have full control on the secondary effects. But I would rather not add this in the codebase, especially hidden under a |
@albertosottile I implemented a proper listener here: #30 |
A
listener
function for macOS is currently missing. As stated in the README, calling this function on this platform raisesNotImplementedError
.EDIT:
Implementation requirements
The
listener
function must:callback
function (Callable[[str], None]
) as its only argumentdarkdetect.theme()
in a loop) as that wastes resourcesThe
listener
function should, if possible:pip install darkdetect[macos-listener]
)Related: #14
The text was updated successfully, but these errors were encountered: