-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support installation in Flatpaks. #70
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,7 @@ sedEscape() { | |
run() { | ||
set -e | ||
|
||
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}/tridactyl" | ||
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/tridactyl" | ||
HOME="${HOME:-$(echo ~)}" | ||
|
||
# Decide where to put the manifest based on OS | ||
# Get OSTYPE from bash if it's installed. If it's not, then this will | ||
|
@@ -58,14 +57,41 @@ run() { | |
native_loc="https://github.com/tridactyl/native_messenger/releases/download/$native_version/native_main-$binary_suffix" | ||
fi | ||
|
||
mkdir -p "$manifest_home" "$XDG_DATA_HOME" | ||
install_to "$manifest_home" "$manifest_home" | ||
|
||
manifest_file="$manifest_home/tridactyl.json" | ||
native_file="$XDG_DATA_HOME/native_main" | ||
for flatpak_dir in ~/.var/app/*/.mozilla; do | ||
[ -d "$flatpak_dir" ] || continue | ||
echo | ||
echo "Detected flatpak installation in $flatpak_dir" | ||
install_to "$flatpak_dir/native-messaging-hosts/" "$HOME/.mozilla/native-messaging-hosts/" | ||
done | ||
|
||
echo "Installing manifest here: $manifest_home" | ||
echo "Installing script here: XDG_DATA_HOME: $XDG_DATA_HOME" | ||
echo | ||
echo "Successfully installed Tridactyl native messenger!" | ||
echo "Run ':native' in Firefox to check." | ||
} | ||
|
||
# install_to takes two arguments: | ||
# 1. The path to the manifest home as seen by the install script. | ||
# 2. The path to the manifest home as seen by Firefox. | ||
# | ||
# For regular Firefox installations, these are the same. They are different in | ||
# the case of sandboxed installations (like Flatpak). | ||
install_to() { | ||
manifest_home_on_host="$1" | ||
manifest_home_in_sandbox="$2" | ||
|
||
mkdir -p "$manifest_home_on_host" | ||
|
||
manifest_file="$manifest_home_on_host/tridactyl.json" | ||
# For Flatpak installations, we must install the native binary inside | ||
# `~/.mozilla/native-messaging-hosts` as well, because everything outside | ||
# of `~/.mozilla` is wiped when restarted. | ||
native_binary_name="tridactyl_native_main" | ||
native_file="$manifest_home_on_host/$native_binary_name" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we're supposed to put anything except the JSON manifests in this folder but it probably doesn't matter. Is there a good reason for abandoning the old I can guarantee that some people will have ill-advised scripts that are rely on the location of the executable, e.g. |
||
|
||
echo "Installing manifest here: $manifest_home_on_host" | ||
echo "Installing script here: $native_file" | ||
|
||
curl -sSL --create-dirs -o "$manifest_file" "$manifest_loc" | ||
curl -sSL --create-dirs -o "$native_file" "$native_loc" | ||
|
@@ -80,7 +106,7 @@ run() { | |
exit 1 | ||
fi | ||
|
||
sed -i.bak "s/REPLACE_ME_WITH_SED/$(sedEscape "$native_file")/" "$manifest_file" | ||
sed -i.bak "s/REPLACE_ME_WITH_SED/$(sedEscape "$manifest_home_in_sandbox/$native_binary_name")/" "$manifest_file" | ||
chmod +x "$native_file" | ||
|
||
## Apparently `curl`'d things don't get quarantined, so maybe we don't need this after all? | ||
|
@@ -91,10 +117,6 @@ run() { | |
# sudo xattr -d com.apple.quarantine "$native_file" | ||
# ;; | ||
# esac | ||
|
||
echo | ||
echo "Successfully installed Tridactyl native messenger!" | ||
echo "Run ':native' in Firefox to check." | ||
Comment on lines
-94
to
-97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that this message is confusing, but I'd rather we improved it rather than removed it totally. E.g. |
||
} | ||
|
||
# Run the run function in a subshell so that it can be exited early if an error | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit nervous about running this on OSX - could you set a flag around line 36 to skip it on them?