I’m trying to set up my UHK to display notification-like text from my computer and then clear it once the user presses any key.
I have figured out how to set LED text indefinitely with setLedTxt 0 BEL (with “BEL” being text that denotes a notification).
What I have not figured out how to do from the reference manual and am not sure are possible:
Sleeping the macro/pausing execution to wait for any keypress at all–I have tried experimenting with ifShortcut, but haven’t gotten anything to work so far.
Resetting the LED text to its default value–it seems like making another call to setLedTxt, but this time with a definite timeout does the trick. But is there a more “proper” way I should be doing this?
Thanks in advance for any pointers. I’m new to UHK macros, so still getting my sea legs.
One last thing: is there anything I should do to manage or prevent multiple concurrent invocations of this macro when invoking with call or exec via serial commands? My thinking is that if this macro gets called a lot without receiving any keypresses/without completing, it would result in duplicate invocations running at the same time. Maybe that’s not a problem and I’m overthinking it. Especially considering that I won’t be spamming this macro to begin with.
Potentially, I could deduplicate calls to this macro on the sending side, but if there’s a proper way to manage this on the UHK side of things, I would vastly prefer that.
And I have this bell function defined in my shell. Depending on the occasion, I might call it myself (e.g. commandThatMightFail || bell, longRunningCommand; bell), or my shell might, according to some extra configuration I have set up that can optionally call bell after any function that takes a long time to run.
# bell.fish
function bell
# uses the terminal's built-in functionality to "ring the bell."
# my terminal (Kitty) makes an audible tone
# and shows a visual indicator
tput bel
# "bell" is the name of the UHK macro to call
type -q uhkcmd && uhkcmd "exec bell" 2> /dev/null
end
Thanks to this UHK macro, I get not only visual and auditory feedback from my terminal, but also visual feedback from my keyboard! That has the advantage of working in the TTY as well.