Auto quit apps like Raycast?

The new raycast eats up my RAM, so I moved to Tinycast. But its missing the auto quit apps after certain minutes of inactivity. I see that there is a variable that can check app inactivity, but I don't think it will work since it would need to check all the time?

I did try a proof of concept with a swift script as well.

btt_preferences_autoclose.swift (4.0 KB)

From chatgpt discussion:

My idea was to build this with one global app-switch trigger plus variables, instead of one trigger per app.

Something like:

  • Use a global “App Did Activate/Deactivate” trigger.

  • Read BTTActiveAppBundleIdentifier.

  • Store the previous active app in a variable, e.g. PreviousApp.

  • When the active app changes, save the current timestamp for the previous app, e.g. LastUsed_com.apple.Preview = current time.

  • Run one periodic check that looks at all running apps.

  • If current time - LastUsed_<bundleID> is greater than e.g. 15 minutes, quit that app.

  • Keep an exclusion list for apps that should never be quit.

  • Optionally use BTTCurrentlyPlaying / BTTCurrentlyPlayingApp to avoid quitting an app that is playing media.

The main thing I’m unsure about is whether BTT can reliably expose the bundle ID of the app that just deactivated, or whether keeping track of the previous BTTActiveAppBundleIdentifier in a variable is the best approach.