Skip to content

Instantly share code, notes, and snippets.

@Lysak
Last active February 5, 2026 20:36
Show Gist options
  • Select an option

  • Save Lysak/4b418c1adf553582574606bf3e228922 to your computer and use it in GitHub Desktop.

Select an option

Save Lysak/4b418c1adf553582574606bf3e228922 to your computer and use it in GitHub Desktop.
Keep Lang Switcher always running on macOS (launchd + AppleScript)

Keep Lang Switcher always running on macOS (launchd + AppleScript)

This setup ensures Lang Switcher 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 Lang Switcher 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.LangSwitcher.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.LangSwitcher</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>
       <string>Lang Switcher</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>
  4. Load the service:

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

🔄 Usage

  • Now, Lang Switcher 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.LangSwitcher.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment