One way of doing this that might save you some effort is writing a plugin for Raycast, but I have no idea whether this covers the use cases you have in mind.
Seems doable: https://github.com/raycast/extensions/blob/main/extensions/o...
(Not affiliated, I just have Raycast installed and use it sometimes)