aboutsummaryrefslogtreecommitdiffstats
path: root/install.sh
diff options
context:
space:
mode:
authorOmar Rizwan <omar.rizwan@gmail.com>2020-10-23 22:03:13 -0700
committerOmar Rizwan <omar.rizwan@gmail.com>2020-10-23 22:03:13 -0700
commit281e0a3d8cbc4ef5e2f2a32d6e347888d36c5209 (patch)
tree588f4666569c41099b97586d9671f768011b050d /install.sh
parenteee57547acb4b9a73dffa3c7cceddd6d5d15e5d7 (diff)
Works in Chrome again! (had to make TabFS name lowercase)
Add install script to cover all the native messaging install cases.
Diffstat (limited to 'install.sh')
-rwxr-xr-xinstall.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/install.sh b/install.sh
new file mode 100755
index 0000000..aa13668
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,54 @@
+#!/bin/bash -eux
+
+OS="$(uname -s)"
+BROWSER="$(echo ${1:-chrome} | tr '[:upper:]' '[:lower:]')"
+
+# https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#Manifest_location
+# https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location
+case "$OS $BROWSER" in
+ "Linux firefox")
+ MANIFEST_LOCATION="$HOME/.mozilla/native-messaging-hosts";;
+ "Darwin firefox")
+ MANIFEST_LOCATION="$HOME/Library/Application Support/Mozilla/NativeMessagingHosts";;
+ "Linux chrome")
+ MANIFEST_LOCATION="$HOME/.config/google-chrome/NativeMessagingHosts";;
+ "Linux chromium")
+ MANIFEST_LOCATION="$HOME/.config/chromium/NativeMessagingHosts";;
+ "Darwin chrome")
+ MANIFEST_LOCATION="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts";;
+ "Darwin chromium")
+ MANIFEST_LOCATION="$HOME/Library/Application Support/Chromium/NativeMessagingHosts";;
+esac
+
+mkdir -p "$MANIFEST_LOCATION"
+
+APP_NAME="com.rsnous.tabfs"
+EXE_PATH=$(pwd)/fs/tabfs
+
+case "$BROWSER" in
+ chrome | chromium)
+ MANIFEST=$(cat <<EOF
+{
+ "name": "$APP_NAME",
+ "description": "TabFS",
+ "path": "$EXE_PATH",
+ "type": "stdio",
+ "allowed_extensions": ["tabfs@rsnous.com"],
+ "allowed_origins": ["chrome-extension://jimpolemfaeckpjijgapgkmolankohgj/"]
+}
+EOF
+ );;
+ firefox)
+ MANIFEST=$(cat <<EOF
+{
+ "name": "$APP_NAME",
+ "description": "TabFS",
+ "path": "$EXE_PATH",
+ "type": "stdio",
+ "allowed_extensions": ["tabfs@rsnous.com"]
+}
+EOF
+ );;
+esac
+
+echo "$MANIFEST" > "$MANIFEST_LOCATION/$APP_NAME.json"