-
Notifications
You must be signed in to change notification settings - Fork 215
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
Pick backend based on screen lock #168
Comments
This is something I've wanted to do for a while, but I'm not sure how to best implement it. For now, I have #125 (which is what I personally use actually) that supports this feature via a meta-backend called backends: [multi]
multi:
locked:
pushover:
user_key: user-api-key
unfocused:
default: {}
focused: {} I'd prefer it be more integrated rather than a meta-backend but can't decide on the best implementation approach (both code & config). You can try it out with |
Oops, just re-read your post. That branch/pr only supports Linux for now. I have no clue how to do this on macOS or Windows, so any help on that front would be very welcome 😃 |
Oh, cool, didn’t realize there was something already underway. I don’t know python very well, but I got this idea from someone who did something similar with just (I think) zsh. Let me see if can find out how he did it. As far as the config part, what you’ve got seems pretty reasonable. Other options that come to mind:
Fair warning, these ideas are very much pre-coffee and may not hold up. 😁 |
Here's a commit that adds MacOS support. I haven't tested it in situ, as I'm using my own zsh solution for this problem currently, but this should give @ianwremmel what he needs. Note that this builds on top of #125, which is like a year behind master. The commit detects whether or not the screensaver is running, not whether or not the screen is locked. Depending on how the user has configured the screensaver and lock behavior, it's possible for the screen to lock without the screensaver engaged, and it's also possible for the screensaver to be on without a lock. I do not know how to detect locked-ness in High Sierra. |
Go for it @ianwremmel, I don't have much time to work on this (not that it's abandoned, I still use ntfy every single time I touch a computer) |
Sounds good. Any pointers on how to use a local checkout instead of the version from pip?
…On Mar 13, 2018, 6:04 AM -0700, Daniel Schep ***@***.***>, wrote:
Go for it @ianwremmel, I don't have much time to work on this (not that it's abandoned, I still use ntfy every single time I touch a computer)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
use:
|
So, I feel like there's an obvious python thing that I just don't know. I've run
|
You should just be able to run |
ah, ok. thanks! I tried that, but it didn't seem to like the multi backend config when I just ran I'm getting the error below when the screen is locked now. I'll dig into that in the next few days.
|
ok, I've worked out a few things:
backends: [multi]
multi:
locked:
pushover:
user_key: REDACTED
unfocused:
default: {}
focused: {} I got the detection working with the following. import Quartz
d = Quartz.CGSessionCopyCurrentDictionary()
screenIsLocked = d.get("CGSSessionScreenIsLocked", 0) == 1 I think Quartz automatically comes in because of the dependency on pyobjc, but pyobjc-framework-Quartz might be required. I think I can tackle point 2. Is point 3 intended? |
My code only detects screensaver-ness, not locked-ness, as per my comment in the code. If you configure your screensaver appropriately, this is a moot issue. Regarding the dual behavior: as I mentioned elsewhere, I am suspicious of the default ‘return True’ statement in the locked decision tree. That might be the cause of your woes. |
Screensaver-ness is fine IMO. I just used locked-ness because they're synonymous because of the way i setup my machines. |
@pcl I'll check that, but I think it's actually the loop in As far as screensaver vs locked, the more I think about it, the more I think using both solutions is correct, but my point last night was poorly worded. What I really meant was "I can't find a way to force the screensaver detection to return True, but the lock check I found works". |
ok, I've updated #170 to use both detection methods. I think everything works, with the caveat of being notified in multiple ways when the screen is locked/screensavered. (I checked if it |
Yeah, you currently get 2 notifications when the screen is locked. This worked fine with how I use the plugin. I use |
Gotcha. Then, I’d say #170 is ready to go. |
Any status on getting the multi backend merged? I'd love to install it without need to git clone and install from source. |
I'd rather not ship without windows support, but I don't see myself adding that anytime soon.. so I guess I ought to merge this stuff. just a quick note, the install from source is pretty straightforward since you can still do it through pip: |
posting this here because i'm using this branch, not the mainline release.
@dschep thanks! that helped a lot; somehow, though, shell integration seems broken. If I explicitly call I've got
any pointers on what might be broken or how to debug? are there changes in master that I should pull in, perhaps for the latest macos release? Will it cause any issues for you if I rebase ianwremmel/ntfy@multi-screenlock on master? |
Similar to #94, it'd be really nice if I could use e.g. macos notifications when the screen is unlocked but switch to pushover if things took long enough that I locked my computer and went for coffee.
The text was updated successfully, but these errors were encountered: