install.sh
#!/usr/bin/env bash
# Installs an extracted version of a notion
# tarball generated by build.sh
set -euo pipefail

# INSTALL_DIR is the directory where Notion will be installed.
INSTALL_DIR="/opt/notion"

WORKING_DIR=$(pwd)

# create_shortcut creates a shortcut for the current user
# to launch Notion from the desktop.
create_shortcut() {
  cat <<EOS >Notion.desktop
[Desktop Entry]
Name=Notion
Name[en_US]=Notion
Comment=Unofficial Notion application for Linux
Exec="/opt/notion/notion"
Terminal=false
Categories=Office;TextEditor;Utility
Type=Application
Icon=${WORKING_DIR}/Notion_app_logo.png
StartupWMClass=notion
EOS
  chmod +x Notion.desktop

  # This can be updated if this path is not valid.
  cp -p Notion.desktop "$HOME/.local/share/applications"
}

install_notion() {
  if [[ -e "$INSTALL_DIR" ]]; then
    echo "Error: $INSTALL_DIR already exists" >&2
    exit 1
  fi

  topDir="$(dirname "$INSTALL_DIR")"
  if [[ ! -w "$topDir" ]]; then
    echo "Error: $topDir is not writable. Re-run with sudo?" >&2
    exit 1
  fi

  mkdir -p "$INSTALL_DIR"

  # Copy all files in the current directory to the install directory.
  cp -rvp ./* "$INSTALL_DIR"

  # Install the notion script to /usr/bin/notion
  ln -s "$INSTALL_DIR/notion" /usr/bin/notion
}
