Last active
July 13, 2025 23:45
-
-
Save ciriousjoker/9b2f4647d378740eb6824ed633341a5f to your computer and use it in GitHub Desktop.
READ COMMENT -- Mac OS: Custom Google Chat PWA that opens with the correct user every time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Save this as "Google Chat.app" | |
-- Check "Stay open after run handler" during save dialog | |
-- Locate "Google Chat.app" and fix the icon yourself (see comment) | |
on run | |
-- This runs once on launch and sets the timer. | |
do shell script "\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\" --app=\"https://mail.google.com/chat/u/1/\" &> /dev/null &" | |
end run | |
on idle | |
-- This delay must be at the start, otherwise the script would immediately close | |
-- because Google Chat isn't open yet. | |
delay 3 | |
-- Check if the "Chat" window is still open. | |
tell application "Google Chrome" | |
try | |
if not (exists (first window whose title contains "Chat")) then | |
-- If the window is gone, quit this app. | |
quit me | |
end if | |
on error | |
-- If Chrome itself was quit, also quit this app. | |
quit me | |
end try | |
end tell | |
-- Tell the app to run this check again in 5 seconds. | |
return 0 | |
end idle | |
on reopen | |
-- This version uses low-level UI scripting to force the window to the front. | |
try | |
tell application "System Events" to tell process "Google Chrome" | |
perform action "AXRaise" of (first window whose title contains "Chat") | |
end tell | |
end try | |
end reopen | |
on quit | |
-- This code runs when you quit the app from the Dock | |
tell application "Google Chrome" | |
try | |
-- Find the window by its title and close it | |
close (first window whose title contains "Chat") | |
end try | |
end tell | |
continue quit | |
end quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nevermind, use this approach: