Skip to content

Instantly share code, notes, and snippets.

@Lysak
Last active August 26, 2025 15:26
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 + AppleScript)

Keep Google Chat always running on macOS (launchd + AppleScript)

This setup ensures Google Chat is always running on macOS.
If the app crashes or is accidentally closed, it will automatically restart.
Unlike open -a, this method avoids stealing focus every time Google Chat launches.


⚙️ Installation

  1. Open Terminal and create a LaunchAgents folder (if it doesn’t exist):

    mkdir -p ~/Library/LaunchAgents
  2. Create a new service file:

    nano ~/Library/LaunchAgents/com.user.googlechat.plist
  3. Paste the following content:

    <?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>ProgramArguments</key>
        <array>
          <string>osascript</string>
          <string>-e</string>
          <string>tell application "Google Chat" to run</string>
        </array>
    
        <key>RunAtLoad</key>
        <true/>
    
        <key>KeepAlive</key>
        <true/>
      </dict>
    </plist>
  4. Load the service:

    launchctl load ~/Library/LaunchAgents/com.user.googlechat.plist

🔄 Usage

  • Now, Google Chat will always stay open.
  • If you close it manually or it crashes, launchd will restart it automatically.
  • To disable the service:
    launchctl unload ~/Library/LaunchAgents/com.user.googlechat.plist

✅ Notes

  • Works with the official Google Chat desktop app (from Google).
  • If you’re using Chrome PWA, adjust tell application "Google Chat" to match your PWA app name.
  • Unlike open -a "Google Chat", this solution prevents the window from becoming active on each restart.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment