-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from amiaopensource/check_connection
check if web connected
- Loading branch information
Showing
1 changed file
with
20 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This allows to open the online version of the Cable Bible, when the computer | ||
# is connected to the Web, and the local version otherwise. | ||
|
||
if [[ "$(uname -s)" = "Darwin" ]] ; then | ||
default_browser=$(plutil -convert json ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist -r -o - | grep https -b1 | tail -n1 | cut -d'"' -f4) | ||
if [ -d /usr/local/Cellar/cable-bible ] ; then | ||
cablebible_path=$(find /usr/local/Cellar/cable-bible -iname 'index.html' | sort -M | tail -n1) | ||
fi | ||
if [ -z "${cablebible_path}" ] ; then | ||
cablebible_path='https://amiaopensource.github.io/cable-bible/' | ||
fi | ||
if [ -n "${default_browser}" ] ; then | ||
open -b "${default_browser}" "${cablebible_path}" | ||
else | ||
open "${cablebible_path}" | ||
fi | ||
default_browser=$(plutil -convert json ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist -r -o - | grep https -b1 | tail -n1 | cut -d'"' -f4) | ||
if ping -c 1 amiaopensource.github.io >/dev/null 2>&1 ; then | ||
cablebible_path='https://amiaopensource.github.io/cable-bible/' | ||
else | ||
cablebible_path=$(find /usr/local/Cellar/cable-bible -iname 'index.html' | sort -M | tail -n1) | ||
fi | ||
if [ -n "${default_browser}" ] ; then | ||
open -b "${default_browser}" "${cablebible_path}" | ||
else | ||
open "${cablebible_path}" | ||
fi | ||
elif [[ "$(uname -s)" = "Linux" ]] ; then | ||
if [ -d ~/.linuxbrew/Cellar/cable-bible ] ; then | ||
cablebible_path=$(find ~/.linuxbrew/Cellar/cable-bible -iname 'index.html' | sort -M | tail -n1) | ||
fi | ||
if [ -z "${cablebible_path}" ] ; then | ||
cablebible_path='https://amiaopensource.github.io/cable-bible/' | ||
fi | ||
xdg-open "${cablebible_path}" | ||
if ping -c 1 amiaopensource.github.io >/dev/null 2>&1 ; then | ||
cablebible_path='https://amiaopensource.github.io/cable-bible/' | ||
else | ||
cablebible_path=$(find ~/.linuxbrew/Cellar/cable-bible -iname 'index.html' | sort -M | tail -n1) | ||
fi | ||
xdg-open "${cablebible_path}" | ||
fi |