Skip to content
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

WiFiTransitions: ”from” never runs because transitions to/from nil are filtered #158

Closed
nriley opened this issue Jan 19, 2020 · 2 comments

Comments

@nriley
Copy link
Contributor

nriley commented Jan 19, 2020

The documentation of WiFiTransitions.actions includes "Transitions through the disabled state are ignored".

Background: I'm migrating my WiFi transitions from ControlPlane, whose WiFi evidence source broke in Catalina and does not seem to be being maintained.

This includes both "from" and "to" actions. But most commonly I go "from" a network, to no network, "to" another network. In that case, the current network is nil in the middle, so the "from" actions never execute.

I could see a few possibilities to fix this: (optionally?) allow triggering on "no network" — which would actually be more consistent with what I want — or just don't save "nil" as the previous network given you'll never act on it in any case, delaying the "from" action until a new network is joined.

These both seem like very small changes so I'm happy to put together a pull request. Thoughts?

@nriley nriley changed the title WiFiTransitions: "from" never runs because transitions to/from nil are filtered WiFiTransitions: ”from” never runs because transitions to/from nil are filtered Jan 19, 2020
@asmagill
Copy link
Member

I haven’t used this spoon (didn’t know it existed actually, so I’ll have to take a look at it) but I can imagine a case where I’d want to know that I had left a network and gone to “no” (or nil) network... Given that my understanding is limited to what you’ve described here, so far, I think I’d rather fire the “to” for nil and then if the next “to” doesn”t follow a “from”, slip a nil “from” in ahead of it... yeah they will fire one right after the other, but its the behavior I’d expect — I can decide if I care about the “from” no network in my callback and just return immediately if I don’t care.

@asmagill
Copy link
Member

Ok having read the description of the spoon now, I guess I think the best approach would be to add a spoon level variable to enable/disable nil notifications. By default, leave it off, so spoon behavior maintains backwards compatibility, but those of us that want to know about these transitions can enable them.

nriley added a commit to nriley/Spoons that referenced this issue Jan 19, 2020
To use, set WiFiTransitions.actOnNilTransitions`.

Fixes Hammerspoon#158.
@cmsj cmsj closed this as completed in 80dd613 Mar 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants