I found @oa-'s answer useful. I used their script as posted in the answer.
(*
1. Save as an Application: Script Editor > File > Export… > File Format: Application
2. Check "Stay open after run handler"
3. Run the app or add it to your login items: System Preferences > Users & Groups > User > Login Items > Press the "+" button
# http://apple.stackexchange.com/questions/269174/disable-the-sleep-function-of-the-macbook-touch-bar
*)
on idle
tell application "System Events" to keystroke (key code 63) -- press fn key
delay 60
end idle
However it adds the applescript application to switcher which is an annoyance to me. To remove the script from the Cmd+Tab
switcher, find the applescript application and edit its Info.plist
file (right click the app file -> Show Package Contents
, open Info.plist
with text editor). You should add
<key>LSUIElement</key>
<string>1</string>
to it so it becomes hidden from app switcher. If you want to trace & kill the app later, use the terminal to hunt it down: ps aux | grep YOUR_SCRIPT_NAME
and kill PROCESS_ID
.
Used for assistance: https://apple.stackexchange.com/a/92017/123820