Jump to content

Using Alfred in screen sharing


Recommended Posts

  • 2 weeks later...

I routinely have three or four Screen Sharing sessions open when I'm managing multiple computers, and I'm hooked on my Alfred Workflows.

 

Toggle Alfred is what we all do as a workaround. A different Alfred Hotkey would pose a problem for machines one uses both directly and remotely.

 

One could propose to Apple that remote computers get first dibs on processing keystrokes, so to activate the local Alfred one would have to first move focus away from the remote screen. Good luck with that.

 

Alfred has become a great program because it is open to suggestions.

 

How would I code this? Presently the Alfred Hotkey toggles Alfred. This is wasteful of precious bandwidth, because Escape also exits Alfred. Instead, Alfred has a valid claim on the Alfred Hotkey when it isn't active. How should Alfred handle a second instance of the Alfred Hotkey, once it has focus? Deactivate and pass the keystroke on.

 

In other words, if you want to just deactivate Alfred, use the escape key. If you also want to pass the keystroke on, use the Alfred Hotkey.

 

This is the easiest kind of code change, because there's no interface to change. Perhaps a note in the documention, but the Alfred GUI stays the same.

 

This is so obvious, I'm surprised it isn't the default for all application hotkeys. I'm stunned that Apple hasn't published a user interface guideline insisting on this behavior.

 

When a remote Screen Sharing session has focus, the effect would be to send the Alfred Hotkey to the remote machine. This is easily learned; it's human nature to try again when something doesn't work the first time.

 

Most of the time, one shouldn't even notice this proposed change. The default Alfred Hotkey, or whatever hotkey one settles on instead, is carefully chosen to not already be in use. It should mean nothing to any program other than Alfred. The only circumstance under which one should notice this change is while screen sharing to a remote computer with the same Alfred configuration, in which case a second instance of the Alfred Hotkey would actually work.

 

I've requested that Alfred consider this change.

Edited by Syzygies
Link to comment
12 hours ago, Syzygies said:

How would I code this? Presently the Alfred Hotkey toggles Alfred. This is wasteful of precious bandwidth, because Escape also exits Alfred. Instead, Alfred has a valid claim on the Alfred Hotkey when it isn't active. How should Alfred handle a second instance of the Alfred Hotkey, once it has focus? Deactivate and pass the keystroke on.

 

This simply isn't possible within the limited API macOS offers for registering hotkeys (without a huge amount of hackery, or resorting to the Accessibility APIs).

 

Alfred doesn't listen for hotkeys, he registers the key combo he is interested in with macOS, then macOS decides when to notify Alfred when this event happens (agnostic of the hotkey used). It's up to macOS, not Alfred, where the event goes. In the case of Screen Sharing, macOS decides if the event goes to Alfred or the Screen Sharing app.

 

Having said that, there is actually a neat workaround which will get you very close to the behaviour you describe using a Workflow.

  1. Set Alfred's default hotkey on your local machine to something obscure so it's no longer used.
  2. Create a workflow with a single Hotkey object set to the hotkey you want to use for Alfred.
  3. Right click on the hotkey you set > Trigger Behaviour > Pass through modifier keys (Fastest)
  4. Set the Action to "Show Alfred"
  5. Select the "Related Apps" tab, select the option that the hotkey is only active when specified apps "don't have focus"
  6. Drop Screen Sharing.app into the list of apps below

With this workflow, the hotkey you want will now show Alfred locally, except for when the Screen Sharing app is active, in which case, the hotkey goes to the remote Alfred.

 

Cheers,

Andrew

 

 

Link to comment
2 hours ago, Andrew said:

Having said that, there is actually a neat workaround which will get you very close to the behaviour you describe using a Workflow.

 

Wow, thanks. This is a neat example showing that I've barely scratched the surface of Alfred as a programming language. The result is exactly what one wants, better than my proposal. If anyone a bit puzzled reading the steps, they only take a couple of minutes to carry out on one machine, and then they sync to other machines.

 

Perhaps there's a workaround, but I encountered one amusing wrinkle: 

 

Syncing Your Alfred Settings Between Macs

Quote

Not all preferences are synced between your Macs, as some can be customised independently on each Mac.

 

Ha! The Alfred Hotkey itself is such a preference. One can't just push the new obscure hotkey to the remote machine, because the original machine will intercept it. A classic paint-yourself-in-a-corner situation. Alas, giving the original machine a different temporary hotkey doesn't solve this, because for some reason one can't set the Alfred Hotkey via screen sharing. I don't understand why, but perhaps this is another behavior forced by the macOS API.

 

In any case, this simply becomes a deferred maintenance issue. I can confirm that Andrew's solution works even if the remote machine is using the same hotkey for both Alfred's default hotkey and also the "Show Alfred" workflow hotkey. There will be a problem later when the remote machine becomes the foreground machine and attempts to control other machines via screen sharing. One will notice then that the Alfred Hotkey needs to be fixed, and hopefully remember all this and fix it. Keep notes.


Droste effect

 

When I learned APL in the 1970's I just had to try its "delete function" operator on itself. When I first encountered a version of screen sharing many decades ago, I just had to try creating a loop. It worked but it wasn't happy. Here, I highly recommend testing this Workflow while looping screen sharing sessions.

 

Droste effect.jpeg

Edited by Syzygies
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...