Skip to content

Instantly share code, notes, and snippets.

@Lysak
Last active July 18, 2026 15:46
Show Gist options
  • Select an option

  • Save Lysak/943c219747f54facd158282234218af3 to your computer and use it in GitHub Desktop.

Select an option

Save Lysak/943c219747f54facd158282234218af3 to your computer and use it in GitHub Desktop.
Keep Google Chat always running on macOS (launchd)

Keep Google Chat always running on macOS (launchd)

Keeps the Google Chat desktop app always open on macOS. If it crashes or you close it by accident, launchd reopens it automatically — in the background, without stealing focus (unlike a plain open -a, which pops the window to front every time).

No script and no config file: a single launchd agent with KeepAlive does the whole job.


⚙️ Installation

  1. Create the LaunchAgents folder (if it doesn't exist):

    mkdir -p ~/Library/LaunchAgents
  2. Add the agent at ~/Library/LaunchAgents/com.user.googlechat.plist (see com.user.googlechat.plist). ⚠️ If your Google Chat is a Chrome PWA, it may be named like Google Chat 1. Check your exact name and put it in the plist:

    ls /Applications | grep -i "google chat"
  3. Load the agent:

    launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.user.googlechat.plist

Done. Google Chat now stays open and reopens itself if closed or crashed.


🔄 Management

Check status:

launchctl print gui/$(id -u)/com.user.googlechat | grep state

Turn it off (this is also how you actually quit the app for good):

launchctl bootout gui/$(id -u)/com.user.googlechat

Turn it back on:

launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.user.googlechat.plist

✅ Notes

  • Works with the official Google Chat desktop app and with Chrome PWA installs — just match the exact app name in the plist.
  • open -g -W -a keeps the app in the background: -g = don't bring to front, -W = wait until it exits so KeepAlive can respawn it cleanly.
  • While the agent is loaded you can't fully quit Google Chat (it reopens instantly). Unload the agent first (launchctl bootout …) when you really want it closed.
  • Want it running only during work hours instead of 24/7? See the companion "Discord work-hours" gist for the scheduled-watcher pattern.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.googlechat</string>
<key>LimitLoadToSessionType</key>
<string>Aqua</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-g</string>
<string>-W</string>
<string>-a</string>
<!-- If your app is a Chrome PWA it may be named e.g. "Google Chat 1" — match it exactly -->
<string>Google Chat</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<!-- optional: reduce respawn spam if something crashes fast -->
<key>ThrottleInterval</key>
<integer>1</integer>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment