Skip to content

Commit

Permalink
Inline applescript
Browse files Browse the repository at this point in the history
  • Loading branch information
anttiharju committed Feb 9, 2025
1 parent 33bcc5e commit 83cd01b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
19 changes: 14 additions & 5 deletions gpr
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,20 @@ fi
SCRIPT_DIR=$(dirname "$(realpath "$0")")

# Get urls of open Safari tabs via AppleScript.
bin="$SCRIPT_DIR/helpers/get_safari_urls.scpt"
if [ ! -e "$bin" ]; then
osacompile -o "$bin" "$SCRIPT_DIR/helpers/get_safari_urls.applescript"
fi
urls=$(osascript "$bin")
urls=$(osascript << 'EOA'
tell application "Safari"
set windowList to every window
set urlList to {}
repeat with aWindow in windowList
set tabList to every tab in aWindow
repeat with aTab in tabList
set end of urlList to URL of aTab
end repeat
end repeat
return urlList
end tell
EOA
)
IFS=', ' # Convert the output to a list

for url in $urls; do
Expand Down
1 change: 0 additions & 1 deletion helpers/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
get_safari_urls.scpt
gclone.cache
11 changes: 0 additions & 11 deletions helpers/get_safari_urls.applescript

This file was deleted.

0 comments on commit 83cd01b

Please sign in to comment.