Using Raycast Notifications in Keyboard Maestro

I'm not entirely sure that this is the right category, as this is my first time posting, but it feels more like a tip than anything else. I get the sense that most Keyboard Maestro users are also probably users of Alfred so I don't think this post will be relevant to those folks, but for those who use Raycast and have always wanted to use the brief notifications that sometimes appear after certain actions are run. It's now possible to do so through Keyboard Maestro.

Let me use a very simple macro as an example. We can all run a simple macro that copies the url from the frontmost tab, but then you can add a shell script action to briefly indicate that the url was copied.

Static Raycast Notification

Running this macro will show this notification for roughly one to two seconds and then disappear:

Result of Static Raycast Notification

You can include SF Symbols and Emoji icons to appear alongside the notification. In this particular example, a static notification is not all that useful. However, you can also make the notification dynamic by adding a few extra actions to the macro:

Dynamic Raycast Notification

Running this macro now shows you the actual url that was copied to the clipboard:

I've been using these brief notifications in many of my macros and have found them to be ideal in many cases. For example, there's a macro I downloaded off the forum some time ago...I can't remember who to credit here but I'm sure someone will know. It's a simple macro that uses ⌘+ A to select all as normal but if you hold down the A key for a second or so it also copies your selection. In the original macro, when you held A long enough a Tink sound would play to indicate that you held it long enough for the selection to be copied. The problem with this for me was that I have speakers that sleep after 20 minutes of inactivity. When my speakers are in that state the tink sound wakes them but I never hear the sound. I've been using a Raycast Notification as a remedy for this. I now hold A long enough and the notification 􀼏 Copied to Clipboard briefly appears. I prefer a brief and subtle visual indicator in cases like this over a sound, even if my speakers were to never sleep.

Another example, and I'm sure this has happened to others, is that sometimes you have a macro that selects an item from a menu but that item is not active so you get an error notification. This happens to me sometimes when I think a window is focused but it's not. I know you can disable the failure notifications but I would still like some indication as to why the macro didn't work, and preferably without flooding the notification center. A Raycast Notification in this instance does this very well.

Select Menu Item Failed

Anyways, if you think this would be useful, you have to first install this extension Raycast Notification. You then bring it up in Raycast and enter the text you want in your notification. After you're done, copy the deeplink by pressing ⇧⌘C. Something like this will show up in your clipboard:

raycast://extensions/maxnyby/raycast-notification/index?arguments=%7B%22title%22%3A%22%F4%80%BC%8F%20Copied%20to%20Clipboard%22%2C%22type%22%3A%22%22%7D

You then place this in a shell action:
open -g "raycast://extensions/maxnyby/raycast-notification/index?launchType=background&arguments=

You simply need to include everything after the = from the deeplink and paste it after background&arguments= in the shell action and then close it with a double quote at the end, so using the example above it would be:

open -g "raycast://extensions/maxnyby/raycast-notification/index?launchType=background&arguments=%7B%22title%22%3A%22%F4%80%BC%8F%20Copied%20to%20Clipboard%22%2C%22type%22%3A%22%22%7D"

You can of course make this process a lot less tedious by using a Keyboard Maestro macro. And you'll have to take some extra steps if you want the notification to be dynamic.

Also, I should mention, the extension that you'll install includes success and failure notifications, which you can select in a dropdown after you've entered the text you want in your notification. However, these two options can not, as of yet, run in the background...so if you use them the Raycast window will come into focus briefly and then your notification will appear. This is a dealbreaker for me so I've been simply using the standard option which will run in the background. Hopefully they change that since I would amost certainly use them. Here's how the success and failure notifications would look:

Raycast Failure Notification
Raycast Success Notification

Of course with SF Symbols and Emoji Icons it's not such a big deal since you can indicate success or failure like in this example:

Emoji Icon

Just add a checkmark instead of an xmark for success. Anyways, I guess this is somewhat of a feature request as well, since it would be nice to have such brief and subtle notifications available in a native KM action. One that doesn't show up only in the top right corner and ends up in the notification center. Sometimes that is useful and what I want, but in many other cases I would prefer something that just disappears.

Thanks for reading and hopefully I've given users of Raycast and Keyboard Maestro some ideas.

6 Likes

To do this thing natively in Keyboard Maestro, there are a couple easy ways.

You can use the Display Text action to display the text as a notification. Or if you want it to be displayed across the screen for 1 second, you can use the same action to Display Text Large:

But if you want more explicit control as described above you can use the Custom HTML Prompt action. It's a bit more tricky if you don't know any HTML, but it's pretty easy if you already have the HTML to tweak it however you want.

Make sure the action is configured to time out after 1 second without any notification or aborting the macro, and the other settings in the Gear menu are appropriate (like Transparent and Floating without a Title).

image
image

The HTML is:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>Keyboard Maestro Form Example Circle</title>
	<style type="text/css">

body {
	background-color: #00000000;
	width: 400px;
	margin: 0;
}


.display {
    background-color: #003050C0;
    color: white;
    height: 50px;
    width: 350px;
    border-radius: 25px;
    text-align: center;
    line-height: 50px;
}

	</style> 
</head>
<body data-kmwindow="SCREEN(Main,MidX)-200,SCREEN(Main,Top,20%),400,100">
<p id="Display" class="display">XXX</p>
<script>
document.getElementById("Display").innerText = window.KeyboardMaestro.GetVariable("Local Title");
</script>
</body>
</html>

But if you are already using Raycast, then the suggestions above are well worth knowing.

3 Likes

Cool to know that it actually can be done through Keyboard Maestro. I can't say I'm surprised, but yeah I don't know any HTML so it's over my head. I did run the HTML that you sent though and I can definitely see that working. I like the system with Raycast since it's not too difficult to implement.

1 Like

You could also consider using this marco:

Not sure if it does anything similar, but I thought I'd mention it.

3 Likes

I actually use several of your macros so I appreciate you sharing. I downloaded your macro just to give it a try. It's very nice, I think I'll actually use it in some cases. Although there's an option in your macro to restore focus, the Raycast Notification is more seamless since it never takes focus, that's probably my only gripe. Your macro is far more customizable however, which I appreciate. Is there a way of fading out the notification as it begins to go away instead of it immediately disappearing? I think that would be a nice touch if possible. Great macro man, and the plus side is that anyone who uses KM can use it, whereas the Raycast notification is only available to those who use Raycast.

Thanks!

Yep, mine too. But there's nothing that can be done about it.

Yes, that would be nice. I don't know if I'll implement it, but it would be cool.

1 Like

Hello Nikolai (@njthebaud) :wave:

Even though you’ve got other solutions suggested to your topic - I find your post very useful for People who trigger a lot of Macros from Raycast.

But the suggestions you’ve got from Peter and Dan are very good and great enhancements to your shown workflow.

Greetings from Germany :de:

Tobias

3 Likes

Appreciate it, glad you found it useful!

1 Like