Goal
For this case, I was interested in building a quick dictation tool that would open already set in my target language ( or
), capture and copy the output to paste in another app. I used to rely on the dictation key in macOS but hated the extra step of selecting the language in the dropdown list.
I figured Iβd cobble something with Drafts since I loved the education experience there and it had loads of scripting capabilities.
My goal would be to add quick dication buttons to my stream deck keys.
Here is my documented take on building this simple automation. Maybe that will be helpful to other folks looking at x-callbacks, Drafts URL scheme and other.
Reasoning
The Drafts app has a very powerful URL scheme that can be used for automation.
It integrates with x-callback-url meaning that upon running an action from the url scheme, you can pass its result to another URL scheme.
The only thing is, while I did use URL-schemes, I never chain two using x-callback before which is why I documented my thinking which I am publishing here.
I surmised it should be possible to do something like:
- Use /dictate url scheme action
- Chain in another URL using x-success
- Use /runAction url scheme action
So, looking closer at the two url scheme actions:
- The /dictate Drafts URL scheme action takes 3 arguments but I only need these 2
-
locale
(ie: en-UK, fr-FR) -
save
(boolean) - if set to false, the dictation will be returned to the callback only - Iβd rather not populate my Drafts with all my text entries.
-
- The /runAction Drafts URL scheme action takes 3 arguments by I only need to be aware of 2
-
text
- the action input - I donβt actually need to append this one, itβs done automatically after running the first step! -
action
- the action name - I want to use βCopyβ
-
|
Wrapping up
So, putting it together, my URL would look like:
drafts://x-callback-url/dictate?locale=fr-FR&save=false&x-success=drafts%3A//x-callback-url/runAction?action%3DCopy
Which runs perfectly fine!
Here are my two language variants for French and American English
- French dictation and copy
drafts://x-callback-url/dictate?locale=fr-FR&save=false&x-success=drafts%3A//x-callback-url/runAction?action%3DCopy
- UK English dictation and copy
drafts://x-callback-url/dictate?locale=en-UK&save=false&x-success=drafts%3A//x-callback-url/runAction?action%3DCopy
Let me know if that was helpful / can be improved / etc!