Skip to content

Commit

Permalink
Update 'Default Browser' scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dehesa committed Feb 22, 2023
1 parent e4f3d17 commit 660dcfb
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 104 deletions.
49 changes: 49 additions & 0 deletions commands/system/default-browser-arc.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/osascript

# Dependency: requires defaultbrowser (https://github.com/kerma/defaultbrowser)
# Install via Homebrew: `brew install defaultbrowser`

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Default to Arc
# @raycast.mode silent
# @raycast.packageName Browser

# Optional parameters:
# @raycast.icon images/arc.png

# Documentation:
# @raycast.author Marcos Sánchez-Dehesa
# @raycast.authorURL https://github.com/dehesa
# @raycast.description Set Arc as the default browser.

set repeatCount to 0

tell application "System Events"
try
my changeDefaultBrowser("browser")
repeat until button 2 of window 1 of process "CoreServicesUIAgent" exists
delay 0.01
set repeatCount to repeatCount + 1
if repeatCount = 15 then exit repeat
end repeat
try
click button 2 of window 1 of process "CoreServicesUIAgent"
log "Arc is now your default browser"
on error
log "Arc is already your default browser"
end try
on error
log "The \"defaultbrowser\" CLI tool is required: https://github.com/kerma/defaultbrowser 🔥"
end try
end tell

to changeDefaultBrowser(thebrowser)
do shell script "
if ! command -v defaultbrowser &> /dev/null; then
exit 1
fi
defaultbrowser " & thebrowser & "
exit 0
"
end changeDefaultBrowser
49 changes: 49 additions & 0 deletions commands/system/default-browser-chrome.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/osascript

# Dependency: requires defaultbrowser (https://github.com/kerma/defaultbrowser)
# Install via Homebrew: `brew install defaultbrowser`

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Default to Chrome
# @raycast.mode silent
# @raycast.packageName Browser

# Optional parameters:
# @raycast.icon images/chrome.png

# Documentation:
# @raycast.author Marcos Sánchez-Dehesa
# @raycast.authorURL https://github.com/dehesa
# @raycast.description Set Google Chrome as the default browser.

set repeatCount to 0

tell application "System Events"
try
my changeDefaultBrowser("chrome")
repeat until button 2 of window 1 of process "CoreServicesUIAgent" exists
delay 0.01
set repeatCount to repeatCount + 1
if repeatCount = 15 then exit repeat
end repeat
try
click button 2 of window 1 of process "CoreServicesUIAgent"
log "Google Chrome is now your default browser"
on error
log "Google Chrome is already your default browser"
end try
on error
log "The \"defaultbrowser\" CLI tool is required: https://github.com/kerma/defaultbrowser 🔥"
end try
end tell

to changeDefaultBrowser(thebrowser)
do shell script "
if ! command -v defaultbrowser &> /dev/null; then
exit 1
fi
defaultbrowser " & thebrowser & "
exit 0
"
end changeDefaultBrowser
26 changes: 0 additions & 26 deletions commands/system/default-browser-chrome.sh

This file was deleted.

49 changes: 49 additions & 0 deletions commands/system/default-browser-chromium.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/osascript

# Dependency: requires defaultbrowser (https://github.com/kerma/defaultbrowser)
# Install via Homebrew: `brew install defaultbrowser`

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Default to Chromium
# @raycast.mode silent
# @raycast.packageName Browser

# Optional parameters:
# @raycast.icon images/chrome-icon.png

# Documentation:
# @raycast.author Marcos Sánchez-Dehesa
# @raycast.authorURL https://github.com/dehesa
# @raycast.description Set Chromium as the default browser.

set repeatCount to 0

tell application "System Events"
try
my changeDefaultBrowser("chromium")
repeat until button 2 of window 1 of process "CoreServicesUIAgent" exists
delay 0.01
set repeatCount to repeatCount + 1
if repeatCount = 15 then exit repeat
end repeat
try
click button 2 of window 1 of process "CoreServicesUIAgent"
log "Chromium is now your default browser"
on error
log "Chromium is already your default browser"
end try
on error
log "The \"defaultbrowser\" CLI tool is required: https://github.com/kerma/defaultbrowser 🔥"
end try
end tell

to changeDefaultBrowser(thebrowser)
do shell script "
if ! command -v defaultbrowser &> /dev/null; then
exit 1
fi
defaultbrowser " & thebrowser & "
exit 0
"
end changeDefaultBrowser
26 changes: 0 additions & 26 deletions commands/system/default-browser-chromium.sh

This file was deleted.

49 changes: 49 additions & 0 deletions commands/system/default-browser-firefox.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/osascript

# Dependency: requires defaultbrowser (https://github.com/kerma/defaultbrowser)
# Install via Homebrew: `brew install defaultbrowser`

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Default to Firefox
# @raycast.mode silent
# @raycast.packageName Browser

# Optional parameters:
# @raycast.icon images/firefox.png

# Documentation:
# @raycast.author Marcos Sánchez-Dehesa
# @raycast.authorURL https://github.com/dehesa
# @raycast.description Set Firefox as the default browser.

set repeatCount to 0

tell application "System Events"
try
my changeDefaultBrowser("safari")
repeat until button 2 of window 1 of process "CoreServicesUIAgent" exists
delay 0.01
set repeatCount to repeatCount + 1
if repeatCount = 15 then exit repeat
end repeat
try
click button 2 of window 1 of process "CoreServicesUIAgent"
log "Firefox is now your default browser"
on error
log "Firefox is already your default browser"
end try
on error
log "The \"defaultbrowser\" CLI tool is required: https://github.com/kerma/defaultbrowser 🔥"
end try
end tell

to changeDefaultBrowser(thebrowser)
do shell script "
if ! command -v defaultbrowser &> /dev/null; then
exit 1
fi
defaultbrowser " & thebrowser & "
exit 0
"
end changeDefaultBrowser
26 changes: 0 additions & 26 deletions commands/system/default-browser-firefox.sh

This file was deleted.

49 changes: 49 additions & 0 deletions commands/system/default-browser-safari.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/osascript

# Dependency: requires defaultbrowser (https://github.com/kerma/defaultbrowser)
# Install via Homebrew: `brew install defaultbrowser`

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Default to Safari
# @raycast.mode silent
# @raycast.packageName Browser

# Optional parameters:
# @raycast.icon images/safari.png

# Documentation:
# @raycast.author Marcos Sánchez-Dehesa
# @raycast.authorURL https://github.com/dehesa
# @raycast.description Set Safari as the default browser.

set repeatCount to 0

tell application "System Events"
try
my changeDefaultBrowser("safari")
repeat until button 2 of window 1 of process "CoreServicesUIAgent" exists
delay 0.01
set repeatCount to repeatCount + 1
if repeatCount = 15 then exit repeat
end repeat
try
click button 2 of window 1 of process "CoreServicesUIAgent"
log "Safari is now your default browser"
on error
log "Safari is already your default browser"
end try
on error
log "The \"defaultbrowser\" CLI tool is required: https://github.com/kerma/defaultbrowser 🔥"
end try
end tell

to changeDefaultBrowser(thebrowser)
do shell script "
if ! command -v defaultbrowser &> /dev/null; then
exit 1
fi
defaultbrowser " & thebrowser & "
exit 0
"
end changeDefaultBrowser
26 changes: 0 additions & 26 deletions commands/system/default-browser-safari.sh

This file was deleted.

Binary file added commands/system/images/arc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added commands/system/images/chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added commands/system/images/firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added commands/system/images/safari.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 660dcfb

Please sign in to comment.