Recently, I’ve became an owner of a Geekboards Macropad. This is a small programmable keyboard: all keys can be binded to macros.
I didn’t have a work need to buy it, my Keychrone K8 covers all my needs, it’s done just for aesthetic reasons. Similar macropads can be found on Amazon.
A few months ago my main working operational system became macOS and here I’ll describe how to bind macros to the macropad and make it possible to call Terminal commands by a one key’s click.
First things first, let’s start from installing The Via. The tool allows in a convinient way to bind values to keys, program macros and bind them also. The Via has autocomplete and supports QMK keycodes due to what keyboard “programming” is not a tough process.
By default the macropad has the following key binding (A,B,C,D,E,F,G as example):
I changed the binding to macros:
Defining of macros starts with openning of macros tab in Via. Let’s bind to Macro 0 the following key sequence: left command + left option + left control + J :
I use keycodes KC_LGUI,KC_LALT,KC_LCTL,KC_J (KC_LGUI for command, KC_LALT for option, KC_LCTL - control, KC_J - J).
Next step is writing of a script that should be executed by Terminal. I used Applescrpt as it’s simple for the purpose:
1tell application "Terminal"
2 -- scripts can be defined on "do script" between squares
3 do script "echo hello"
4end tell
Scripts can be written and tested via built-in macOS Script Editor.
Next stop is built-in Automator. Select Quick Action
Find Run AppleScript and paste there the “hello” script:
Click Play button and a terminal will execute echo hello
script.
Final step is to bind Actuator Quick Action to key with Macro 0. Save Quick Action as echo hello and open System Preferences -> Keyboard -> Shortcuts, select Services tab and find echo hello in list:
Click add shortcut and type a key that binded to Macro 0. Now echo hello service binded to key and can be called with single typing.
With first use of key macOS can ask you for granting rights to Finder.
Now that’s all. I attached some scripts for launching working environments, docker scripts by the way. Also via AppleScript can be automated a big range of from day to day routings.
I didn’t want to use third party for the case but they exists:
- Alfred
- Apptetive
- KeyMaestro
- …