I recently wanted a command line based HomeKit app, I don’t think any exist. I guess I’ll have to learn Swift, and write one. This will take a while, probably a very long while though, so I found a temporary fix that will be useful, even after the app is finished.
, typing to Siri from the command line.
Setting up typing to Siri from the command line.
1. download cliclick.
it’s a cool little command line tool that lets you simulate key presses and mouse events, and then input text into interfaces they bring up. the easiest way to get it is through Homebrew.
brew install cliclick
2. enable type to Siri
go to preferences, accessibility, Siri, and check the enable type to Siri box.
3. change the Siri key press to FN and space.
Go to Preferences, Siri. the Siri shortcut key press options are in a pop-up box. Also, VoiceOver now calls the FN key “globe symbol with meridians”.
4. first time typing to Siri with cliclick
brings up a security dialog. You will have to go to Security, Privacy, and allow terminal to control Siri.
5. write a shell function to make it easy.
You could start controlling Siri from your terminal prompt as is, but you’ll have to type a bunch of mumbo-jumbo every time. Shell functions are very useful, and can also be used in aliases and full shell scripts. In this case, a shell function makes controlling Siri with cliclick much easier, so let’s do it.
Copy the following function into a file hopefully of other functions you have.
begin copying next line:
cliclick kd:fn kp:space ku:fn w:250 t:”$1″ kp:return
stop copying and end of previous line.
If you’ve never heard of a shell function before, make a new file called functions.sh and paste this into it.
then save it to a folder. run the command
chmod 555 ./functions.sh
from the folder where you placed it.
then when in your terminal shells type
to keep it in memory.
better yet, put that line above in your .bashrc file so it loads every time a new shell opens.
Finally, we’re all done. It’s all set up, and ready to go.
siricli “what time is it”
If your Siri command is more than one word, you will have to incase it in quotes. Also, Siri won’t return text that VoiceOver can automatically read, so you’ll need to leave “voice feedback” in Siri preferences on.
siricli “turn on lights”
will turn on your lights, Siri will speak its response as if you had spoken the command.
This is somewhat useful, you can type to Siri from the terminal, this means you can use it in aliases and scripts. Scripts can’t get anything back from Siri yet, but it could still be used as destinations for scripts that have done previous logic and arrived at some Siri command.
It’s not that command line HomeKit app I still want, but it gives me some capability for now, and will probably still remain in my toolbox even if that app ever gets written.