Stream Deck


#1

So I am using Stream Deck by El Gato to trigger macros. Problem is when I press the Stream deck button it takes the focus off the current browser window and my macro wants to start by going to the website address and copying it… which would all be fine except that the focus has gone off the webpage window and so the command L and command C actions no longer make sense. So the problem is that, after pressing the key in Streamdeck I need to return focus to the app that was at the front (in focus) just before I pressed the Streamdeck button…

Anyone know of a way to do this? BTW I don’t mean one particular browser because then I could just specify it… he browser could be one of 4, say, and I need it to focus back on whatever browser was at the front when the button was pushed.

Cheers.


#2

You might be able to just use the Switch to Last Application action to switch back to the browser.

If the browser was Safari or Chrome, you can use the SafariURL token or the ChromeURL token, or in 8 you will be able to use the FrontBrowserURL, but they only work with Safari/Chrome.


#3

Primarily I’m coming out of Opera (my current favourite browser).


#4

Opera has no AppleScript support, so the only options are to UI control it somehow.

Keyboard Maestro can track the last application, so you could make a macro that is globally active, and that notes whenever the front application is Opera, Safari, Chrome, or any other browser you care about. Then your macro could switch back to that application before continuing.


#5

Oh how awesome it would be if KM supports StreamDeck! And puts the Macro Icon on it’s buttons! It would be a killer!


#6

Bump! I concur with this feature request. I just bought an Elgato Stream Deck specifically to use with Keyboard Maestro. It'll be great as-is, but official support could take it to the next level. It's a fantastic little piece of hardware that's born for this task.


#7

I'll follow on.. I have also purchased a stream deck and have found it amazingly customizable (if you don't use the provided "Stream Deck" app from Elgato).

Here are my notes:

  • If you don't use the Stream Deck software (don't even run it) the buttons are recognized by KM as USB Device Key triggers
  • You can use (depending on your language of choice) a library to interface directly with the Stream Deck to set the icons to whatever you choose. I use:
    https://github.com/abcminiuser/python-elgato-streamdeck
  • My configuration (really a fun project during the Christmas break) is something like this:
    • A MongoDB with stream deck 'profiles' ... each profile contains information about each button (icon and 'badges')
    • badges are a 'script' that I run which get a number that I can use to 'badge' my icon before pushing it to the stream deck button. I use Pillow for the icon drawing.
    • KM runs the python script that updates the icons in the current profile periodically (to update the numbers in the badges
      image
      (now I notice my number is off-center and it's killing me).
    • KM updates the profile every time I switch apps (changing to a different profile when appropriate).
  • Miscellaneous:
    • I have KM kick the brightness down when I'm idle, and bring it back up when I'm back on my Mac
    • I have a lot of plans for how I can do some more contextually appropriate icons. The possibilities are endless!

Hope that helps.. I'm thinking of starting up a GitHub repo for all this nonsense, but my code is pretty ugly atm.


#8

The brightness down on idle sounds interesting. Can you share this one? :slight_smile:


#9

Pretty straight forward using the python Elgato stream deck library


And here's the macro for bringing back up the brightness:

I don't really know of a way to monitor for 'NOT IDLE'.. so I just use the trigger 'any application activates'


#10

Here's a more refined 'idle' and 'activity' monitor (also fades the brightness)
This has the advantage of making the stream deck dim when I manually lock the display.



#11

There is an Idle trigger which is probably better than using a periodic check (frequently periodic triggers will cause problems since a triggered macro will cancel things like the Conflict Palette).


#12

OK, good to know. Question about the periodic triggers. Does a periodic trigger that, say, checks for the screensaver() have performance issues that I should be aware of? Or would there be a better way to check for that?


#13

There is no trigger to detect when the screen saver is activated, so there is probably no better way to do it, however unless you manually activate the screen saver, the Idle trigger should be roughly equivalent anyway. If you manually activate the screen saver, change to using a macro that activates the screen saver and then performs your macro actions.

There is no steep performance issue with using a periodic macro every 5 seconds (not in terms of CPU or Energy, not unless the macro is fairly energy intensive itself). However, as I mentioned, since any macro triggering cancels things like the Conflict Palette, Typed String trigger sequences, and “for one action” macro groups, having any kind of periodic macro running continuously will have a negative impact.


#14

Thanks for responding. I’ve fixed up the idle trigger to not use the periodic trigger.

I’ve also changed the Activity trigger to use the trigger “when Any Application activates”. It’s obviously not perfect. But it’s good enough for my purposes.

Unless you can think of another trigger for the opposite of idle.


#15

Johns, do you plan on sharing your latest version? :grinning:


#16

Here is the final version, works quite well

Idle monitor:

Active monitor:

John


#17

Thanks Johns - this is awesome!


#18

badges are a 'script' that I run which get a number that I can use to 'badge' my icon before pushing it to the stream deck button. I use Pillow for the icon drawing

This sounds intriguing -- is it making icons based on the script icons in keyboard maestro? Or is this strictly about placing updated numbers on icons that represent lists of items?


#19

The script builds icons based on a PNG (base icon) and then I "Draw" the badge using Pillow (draw red circle, fill with number, etc...)


#20

If you ever put that all up on GitHub it'd probably cause me to start learning Python. Sounds great.