Toggle Cycle Touch Bar Macbook - Automator

 Hi, hi! It's been quite long since I posted something, so.. here I am.


As you might know, I've been using Macbook Pro Touchbar for more than a year. More often than not, I use the "Expanded Control Strip" mode for my Touchbar.


Why?

I just don't think it's that useful for me. I love being able to mindlessly touch my Touchbar to increase volume and such, like the usual Mac keyboard. But, when I started to use Twitter app... I realize that I need emoji, and it's easier to choose from Touchbar than on screen.


"Why don't you just use the Fn key to show app controls?"

It's a fuss and honestly it's tiring to keep pressing the Fn button. Then, I remembered about Automator and its ability. Since I don't really understand much about Automator.. Google to the rescue. Yet, there aren't that many people who've used Automator for toggling Touch Bar? I thought people were protesting about Touch Bar?

The only code I found is from cfriend on Keyboard Maestro forum (link). I used his code with a few modifications, because when I tried to copy paste it as instructed, it's not working so I had to fix it myself.


So, here's the code that I fixed for Automator.

on run {input, parameters}

tell application "System Preferences"
activate
reveal pane id "com.apple.preference.keyboard"
end tell
delay 0.5
tell application "System Events" to tell application process "System Preferences"
set currentState to value of attribute "AXValue" of pop up button 2 of tab group 1 of window "Keyboard"
if currentState is "Expanded Control Strip" then
set newState to "App Controls"
tell pop up button 2 of tab group 1 of window "Keyboard"
perform action "AXShowMenu"
tell menu 1
click menu item newState
end tell
end tell
else if currentState is "App Controls" then
set newState to "Expanded Control Strip"
tell pop up button 2 of tab group 1 of window "Keyboard"
perform action "AXShowMenu"
tell menu 1
click menu item newState
end tell
end tell
else if currentState is "Expanded Control Strip" then
set newState to "App Controls"
tell pop up button 2 of tab group 1 of window "Keyboard"
perform action "AXShowMenu"
tell menu 1
click menu item newState
end tell
end tell
end if
end tell


quit application "System Preferences"

end run


It's easy to automate it. Just open Automator app, create Workflow, then choose 'Run Apple Script'. Copy and paste the code, save it, voila! 

To make it even easier, I mapped keyboard shortcut from System Preferences - Keyboard - Shortcut - Services. Scroll down a little bit, under General, there's your Automator Workflow that you can map the keyboard shortcut to.

Yeah, I gotta admit that this isn't the perfect solution but I guess it's better than having to go through System Preferences and change it manually...

Comments

Popular posts from this blog

Review Sakumini Y2 Mini: Murah Meriah Mantap

How To Solve Choppy Bluetooth Audio - Mac OS Catalina

Sometimes... I Feel Like,