简体   繁体   中英

Is there any way to avoid the Touch Bar of Macbook Pro from sleeping?

I've found that the Touch Bar of my MacbookPro2018 13" had square flickers on and off. I've learned from Google that it's a hardware problem of Mbp, but I can't get it repaired immediately:(

I found that it only happens when the Touch Bar is sleeping. If I keep operating my computer and keep the Touch Bar awake, the problem will not occur. So I want to find a way that can avoid Touch Bar from sleeping.

I've made efforts to simulate a keypress event repeatedly (like press "fn" for each 60s) to keep it awake, but the following ways I tried didn't work.

  1. AppleScript

     repeat while true tell application "System Events" to keystroke (key code 63) delay 60 -- use sec end repeat
  2. PyUserInput

    ... while True: k = pykeyboard.PyKeyboard() k.press_key('Command') # Cmd is an alternate of fn time.sleep(1) # use sec k.release_key('Command') time.sleep(60) # use sec
  3. Java Robot
    ... while (true) { robot.keyPress(KeyEvent.VK_CONTROL); robot.delay(1000); // use ms robot.keyRelease(KeyEvent.VK_CONTROL); robot.delay(60000); // 60s }...

The problem is, though the scripts above can actually 'simulate' the keypress events (the keypress events really took place), the events may have differences from the physical/true press event so they can't awake the Touch Bar.

So is there any way to avoid the Touch Bar from sleeping? or is there any way to simulate physical press event (I don't want to press my fn for each 60s when I'm watching videos, lol)

Thanks for your answer: : )

The easiest solution I found was to use

caffeinate -d

No admin access required or programming. Simply run it in a terminal and it will keep all your screens on infinitely. Watch out that you don't leave your macbook unattended though:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM