April 19th, 2020 79 minutes. BetterTouchTool takes a Mac's input devices and turns them into automation triggers. It can transform the Touch Bar into a customized set of tools and make a Trackpad or Mouse much more powerful. This week Stephen and David dive into this utility and what it can do. This episode of Mac Power Users is sponsored.

Tool

I usually need to see all hidden files in Finder, so I used to just have them showing all the time. Being a long time Gnome user (and an Ubuntu one) I learned to love the joy of Ctrl-H to toggle between visible and invisible hidden files, so I thought that Cmd-H would do the same, which it doesn’t.

  1. Kensington's award-winning TrackballWorks™ has been consolidated into KensingtonWorks™ to provide a simplified software solution to accommodate all of your Kensington trackballs, mice, and presenters.We are phasing in versions of KensingtonWorks™ to accommodate different products and models. View the new KensingtonWorks™.
  2. Better Touch Tool is the gateway to modern Mac customization, I wish more folks would stop bitching about the Touch Bar and get into hacking it. EricWVGG said about 3 years ago.
  3. TLDR: Use this BetterTouchTool preset to display touch bar buttons for triggering Alfred workflows when the Alfred search bar is activated with a keyboard shortcut. Inspired by: Here's what it looks like (workflows not included): It works by: Using BTT to setup a keyboard shortcut that simultaneo.

Seeing hidden files all the time wouldn’t be bad if not for the behated .DS_Store files showing up in every folder and, worst of all, in my Desktop! I try to keep my Desktop clean, no icons at all, just beautiful pictures I get from the nice Kuvva app. I don’t use Desktop shortcuts anyway, Spotlight is my friend.

So, there is a way to add the Ctrl-H behavior to Mac OS, kinda-sorta, and this is the best I could get so far.

Step 1: create a simple shell script
The command to show/hide hidden files is defaults write com.apple.Finder AppleShowAllFiles YES, changing the last word to NO if you want to hide hidden files again.
To make the shortcut behave as a toggle, we just create a “sentinel” hidden file (we created a hidden file for your hidden files so you can hide your hidden files etc..) to save the current state.

Here’s the script

As you may have noticed, we kill Finder so it reloads the defaults, otherwise it looks like nothing happens. Finder reloads itself, so it’s safe to kill it. There’s a little gotcha: at least in Lion it looks like it doesn’t save its current state all the time, so run the script only when you don’t care about the currently open windows. Results may vary, and even in Lion as I said the behavior is not 100% consistent.

Step 2: save the script with a .command extension and make it executable
I’m not entirely sure that this is needed in Mac OS, but I’m too lazy to check. Plus, it’s super easy and it’s the same thing you would do in Linux.

To make it executable, just open a terminal and type

Of course you need to cd into the same folder as your script, or use the absolute path of your script from whatever folder.

Step 3: choose your preferred keyboard shortcut tool
Ok so this is where you can choose how to launch the script. I strongly prefer the OSX-ified Ubuntu-esque way of just pressing Cmd-H (Cmd being OSX’s Ctrl in most cases) since I never use the shortcut to hide windows, and it’s what comes most natural to me. However, this requires using a third-party tool to launch apps using shortcuts; my weapon of choice is the awesome Better Touch Tool, which I already use to enable 3-finger-click gestures to open links in new background browser tabs (again, this is the equivalent of Gnome’s middle-button click with an external mouse).

There are several alternatives, the most popular being Alfred, I guess. I never felt the need for leaving spotlight thus far, so I don’t know much about how you configure shortcuts for that, but I read it’s one of its features.

Step 3a: using Better Touch Tool
This is very easy: open BTT’s preferences, go to Global (left column, should be selected by default), Keyboard tab, click on the “Add new shortcut” button, click on the Keyboard Shortcut field, press your shortcut of choice and choose “Open Application/File/Script…” from the rightmost menu. Then, select your script.

Download

Step 3b: using Spotlight
You can always type the name of your script in spotlight and select it; the downside to this is that it may never become the Top Hit, or at least it didn’t when I tried, so you’d have to select it with the arrow keys..

Step 4: hide the terminal once the script is done
I don’t want the terminal to stick around even after the script is done, so I have it close automatically when done.

Open a terminal window, go to Terminal/Preferences/Settings tab/Shell sub-tab and change the value for “When the shell exits”. I chose “Close if the shell exited cleanly”, but you can also choose “Close the window”. I like to see error messages if something goes wrong, though..

Love it or hate it, it seems that the Touch Bar is here to stay on the MacBook Pro. As such, it seems wise to me to make it more useful.

A little backstory first, though… earlier this year, David Sparks finally talked me into buying a Stream Deck to use at my desk. As with most things, he was right about how much I would come to love it.

The Stream Deck is incredibly flexible, but one of my most common use cases is to tap a single button on it to open a bunch of related Safari tabs when it comes time to prepare for a show.

Better touch tool btt

For example, if I press the button with the MPU logo, it opens these pages:

  • MPU episode schedule
  • Folder of MPU Outlines
  • The MPU page in Relay’s ad-tracking system
  • The MPU page in the Relay FM CMS

I’m doing this via with Keyboard Maestro, another incredibly flexible tool. Here’s what that looks like, with my secret URLs redacted:

As you can see, on my Mac Pro, this is triggered by a specific button my Stream Deck, as pictured above.1

To re-use these macros on my MacBook Pro, I made a copy of them in Keyboard Maestro, which I have sync its data over Dropbox.

Better Touch Tool Midi

I then fired up BetterTouchTool, which among many other things, allows you to create custom UI elements on your notebook’s Touchbar, tying them to a wide range of actions. Turns out, you can even have BetterTouchTool become a trigger for Keyboard Maestro.

First, create a button in the Touch Bar section of BetterTouchTool, or a group that you can place buttons in, like I have:

The action you need to use is named “Execute Terminal Command (Async, non-blocking),” which makes the button fire off a script. Here’s the script itself:

osascript -e 'tell application 'Keyboard Maestro Engine' to do script 'PLACEHOLDER'

Where I have that placeholder text, you’ll need to paste in the UUID of the Keyboard Maestro macro you want to execute. To get that, you will need to select “Copy as UUID” in Keyboard Maestro:

… and then paste it into BetterTouchTool.

(While in Keyboard Maestro, be sure to set the trigger for the macro to be a script.)

When this is all done, you can tap a button on the Touch Bar and fire any Keyboard Maestro macro you desire.

Happy automating!

Better Touch Tool App

  1. The non-show buttons control various lights in my office and control media playback on the computer. The Migration Assistant icon launches my normal set of apps after a reboot. ↩