"After Mac Wakes From Sleep" triggered after Quitting Preview.app

I'm here to report a very strange bug. When I quit Preview.app, BTT triggers my "After Mac Wakes From Sleep" actions. It also restarts itself. It doesn't happen if I untick "Restart BTT after Wake from Sleep" setting. So the thing is that after quitting Preview.app, BTT thinks the computer has woke from sleep. Weird isn't it?

It started happening after updating to Monterey (from Mojave, so can't tell if Monterey is the cause or if another intermediary version was).

I don't have any custom shortcuts (or even anything) configured in BTT for the Preview app.
It seems to only happen with CMD+Q shortcut, not when going to Preview>Quit. So I tried to make a shortcuts in BTT to trigger the menu action when pressing CMD+Q, but the issue persisted. The only workaround which works is using the "Quit app behind cursor" action, but it requires having the cursor on the app, so it's not good. Unfortunately, there's no action to quit the focused app (I guess it's because it can be done with sending CMD+Q to the app, but in my case it would have been a good workaround).

I really have no idea of what can cause this behavior.

I've attached a video. As you can see, when pressing CMD+Q in Preview.app, BTT exits directly, then it execute my "After Mac Wakes From Sleep" trigger (in which I have added an action to show a HUD for easier troubleshooting). (I've recorded from my phone and not screen record so that you can see TouchBar shutting down etc…).

Affected input device (e.g. MacBook Trackpad, Magic Mouse/Trackpad, Touch Bar, etc.): whole app


Video of the issue:

My "After Mac Wakes From Sleep" settings:

Device information:

  • Type of Mac: MacBook Pro 2018
  • macOS version: Monterey 12.3.1
  • BetterTouchTool version: 3.779

that’s really weird. I’m general BTT listens to the system provided notifications for sleep/wake.

Could you go to help-> export diagnostic debug information and send the result to andreas@folivora.ai?

Yeah, this is as if the system was sending Wake events when quitting Preview app… Anything I can check in Console.app to check if those events are somehow sent? I've already tried looking for BTT logs in Console but it's flooding so I couldn't find anything relevant.
As you've requested, I've send debug information to your email.

Hey Andreas!

Unfortunately this issue is still happening and it's irritating to face this several times a day :confused:
After a few months with this issue, I can tell it happens with any app, when it quits. It's not only when using keyboard shortcut (CMD + Q), contrary to what I thought initially. It just happened now when clicking an "Install update and relaunch" button in an app. Probably BTT misinterprets some system notifications sent when apps are being quitted, and guesses it awakes from sleep.

Don't you think I can investigate this issue myself to help you fixing it? Probably by checking for said notifications in Console.app.


I haven't been able to reproduce this, but I think you can fix it by disabling the restart after sleep option:

I don't think you'll be able to see the notifications as they are more low level. I'll check whether I can add some more logs to see what's happening

Yeah it will probably help, but I had to tick this option long time ago for some reason (can't recall why). I'll untick it for now, maybe what I was trying to workaround isn't needed anymore.

Though, I guess it will only prevent having the TouchBar from restarting, it will probably keep triggering my "After Mac Wakes From Sleep" actions.

Will report back.
See you :v:

After a few months with "Restart BTT after wake from sleep" setting disabled, I can confirm that I don't face the issue anymore. Not sure how this setting can cause such behavior, but at least this workaround solves the issue. Thanks for the advice!