Skip to content

Instantly share code, notes, and snippets.

@ryantanner
Created March 13, 2020 17:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryantanner/211b17c304221a75bcb55b74d5256596 to your computer and use it in GitHub Desktop.
Save ryantanner/211b17c304221a75bcb55b74d5256596 to your computer and use it in GitHub Desktop.
Creating a "hot mic" icon with BetterTouchTool

This describes how to create a hot mic icon in the Touch Bar, like this: https://twitter.com/youfoundryan/status/1238507646677700608

  1. Install BetterTouchTool (https://folivora.ai/)
  2. Create a new Touch Bar widget of type "Apple Script/Javascript Widget". You don't need a trigger.
  3. Paste the contents of mic_state.scpt into the script box.
  4. Set the "Alternate Color Regex" to "off".
  5. Switch to the "common" widget settings pane. Set the button background color to red. Set the "Select Button Icon" to the mic and the "Alternate Button Icon" to the mic with a line through it.
  6. Check "show only icon, no text"

I also assigned a FN key on my external keyboard to toggle the mic:

  1. In the Keyboard Shortcuts pane of BTT, add a new keyboard shortcut.
  2. Assign whatever keystroke you want.
  3. I enabled the HUD overlay to say "Toggling Mic" when I trigger it.
  4. Assign an action to the trigger of type "Run Apple Script (async in background)"
  5. Paste the contents of mic_toggle.scpt into the script box
if input volume of (get volume settings) is 0 then
return "off"
else
return "on"
end if
property storedInputLevel : missing value
if input volume of (get volume settings) is 0 then
-- we're muted, so it's time to unmute
-- get the saved input level, and restore it
set volume input volume storedInputLevel
else
-- we're unmuted, so it's time to mute
tell application "System Events"
-- save the current input volume setting --
set storedInputLevel to input volume of (get volume settings)
end tell
-- mute the input
set volume input volume 0
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment