|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# @raycast.schemaVersion 1 |
| 4 | +# @raycast.title Open Google Meet |
| 5 | +# @raycast.mode silent |
| 6 | +# @raycast.packageName Google |
| 7 | +# @raycast.icon images/logo.png |
| 8 | +# @raycast.author Mujib Azizi |
| 9 | +# @raycast.authorURL https://github.com/mujibazizi |
| 10 | +# @raycast.description Start a Google Meet session |
| 11 | + |
| 12 | +open https://meet.google.com/new |
| 13 | + |
| 14 | +MAX_TRIES=10 |
| 15 | +TRIES=0 |
| 16 | + |
| 17 | +DEFAULT_BROWSER=$(defaults read ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist | awk -F'\"' '/http;/{print window[(NR)-1]}{window[NR]=$2}') |
| 18 | + |
| 19 | +get_url () { |
| 20 | + if [ "$DEFAULT_BROWSER" = "com.google.chrome" ]; then |
| 21 | + URL=$(osascript -e 'tell application "Chrome" to URL of active tab of front window as text') |
| 22 | + elif [ "$DEFAULT_BROWSER" = "com.brave.browser" ]; then |
| 23 | + URL=$(osascript -e 'tell application "Brave" to URL of active tab of front window as text') |
| 24 | + elif [ "$DEFAULT_BROWSER" = "com.apple.safari" ]; then |
| 25 | + URL=$(osascript -e 'tell application "Safari" to return URL of front document') |
| 26 | + elif [ "$DEFAULT_BROWSER" = "org.mozilla.firefox" ]; then |
| 27 | + URL=$(osascript -e 'tell applcation "Firefox" to activate') |
| 28 | + echo "There is no support for Firefox yet. Please copy the URL manually" |
| 29 | + exit 0 |
| 30 | + fi |
| 31 | +} |
| 32 | + |
| 33 | +while true; do |
| 34 | + ((TRIES++)) |
| 35 | + |
| 36 | + # Allow some time between each iteration to perform an attempt |
| 37 | + sleep 1 |
| 38 | + |
| 39 | + # As we're doing `while true`, we do want to make sure we can |
| 40 | + # exit the script when we feel we've tried too many times. |
| 41 | + if [[ "$TRIES" -gt "$MAX_TRIES" ]]; then |
| 42 | + echo "Could not copy Google Meet url" |
| 43 | + break; |
| 44 | + fi |
| 45 | + |
| 46 | + get_url |
| 47 | + |
| 48 | + # First, we'll check if we are still on the Google Meet page. |
| 49 | + if [[ $URL != "https://meet.google.com"* ]]; then |
| 50 | + continue |
| 51 | + fi |
| 52 | + |
| 53 | + # Next, we want to make sure it's not still loading. |
| 54 | + if [[ $URL == *"new"* ]]; then |
| 55 | + continue |
| 56 | + fi |
| 57 | + |
| 58 | + echo $URL | pbcopy |
| 59 | + echo "Copied Google Meet url" |
| 60 | + break |
| 61 | +done |
0 commit comments