Skip to content

Instantly share code, notes, and snippets.

@gabrieleara
Last active November 18, 2020 15:55
Show Gist options
  • Select an option

  • Save gabrieleara/684882880c8c057858732b5e40032aa8 to your computer and use it in GitHub Desktop.

Select an option

Save gabrieleara/684882880c8c057858732b5e40032aa8 to your computer and use it in GitHub Desktop.
#!/bin/bash
(
set -e
command -v nativefier >/dev/null 2>&1 || {
echo "ERROR: The webinstall command requires nativefier to be installed!"
false
}
command -v python3 >/dev/null 2>&1 || {
echo "ERROR: The webinstall command requires python3 to be installed!"
false
}
mkdir -p $HOME/.userapps
mkdir -p $HOME/.local/bin
cd $HOME/.userapps
echo "# Forwarding arguments to nativefier application..."
nativefier -p linux -a x64 "$@" | tee /tmp/nativefier.log
dirname=$(grep /tmp/nativefier.log -e "App built to " | sed -E 's/App built to ([^,]+).*/\1/' | xargs)
name=$(basename "$dirname" | sed 's/-linux-x64//')
lname=$(echo "$name" | tr '[:upper:]' '[:lower:]')
wmclass=$(cat "${dirname}/resources/app/package.json" | python3 -c "import sys, json; print(json.load(sys.stdin)['name'])")
rm /tmp/nativefier.log
ln -fs "${dirname}/${name}" $HOME/.local/bin/${lname}
cat >"$HOME/.local/share/applications/$lname.desktop" <<EOF
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=${name}
Comment=${name} (created with Nativefier)
Terminal=false
Exec=${lname} %U
Icon=${dirname}/resources/app/icon.png
Categories=Network;
StartupWMClass=${wmclass}
EOF
echo "# ${name} installed successfully! You can start it by running \`${lname}\` or by using the desktop entry!"
echo "# NOTICE: this may require you to log out and then log in again!"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment