#!/bin/bash # Installs CoScribe 2.1.0 on Linux (x86_64) for this user, no sudo needed: # curl -fsSL https://coscribe.anthony-tong.com/install-linux.sh | bash # curl -fsSL https://coscribe.anthony-tong.com/install-linux.sh | bash -s -- --uninstall # Puts the AppImage in ~/Applications (it updates itself there), a `coscribe` command in ~/.local/bin, # and a menu entry; MuseScore files (.mscz, .mscx) list it under "Open with" (MuseScore stays their default). set -euo pipefail UNINSTALL=0 for arg in "$@"; do case "$arg" in --uninstall) UNINSTALL=1 ;; *) echo "Unknown option: $arg (did you mean --uninstall?)" >&2; exit 1 ;; esac done APPDIR="$HOME/Applications" APP="$APPDIR/CoScribe.AppImage" BIN="$HOME/.local/bin/coscribe" DATA="${XDG_DATA_HOME:-$HOME/.local/share}" DESKTOP="$DATA/applications/coscribe.desktop" MIMEXML="$DATA/mime/packages/coscribe.xml" ICON="$DATA/icons/hicolor/256x256/apps/coscribe.png" refresh() { command -v update-mime-database >/dev/null && update-mime-database "$DATA/mime" >/dev/null 2>&1 || true command -v update-desktop-database >/dev/null && update-desktop-database "$DATA/applications" >/dev/null 2>&1 || true } if [ "$UNINSTALL" = 1 ]; then rm -f "$APP" "$BIN" "$DESKTOP" "$MIMEXML" "$ICON" refresh echo "Removed CoScribe. Your scores, and settings in ~/.config/CoScribe, are left where they are." exit 0 fi if [ "$(uname -m)" != x86_64 ]; then echo "CoScribe for Linux is built for x86_64 only (this is $(uname -m))." >&2; exit 1 fi if pgrep -f "$APP" >/dev/null 2>&1; then echo "CoScribe is running. Quit it and run this again." >&2; exit 1 fi BASE="https://dl.anthony-tong.com/coscribe" FILE="CoScribe-2.1.0-linux-x86_64.AppImage" SHA="e77fa985f5d7bd7fbb3048d6961d47ce7fecf83be17442b8902567eaa1da4ee6" TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT echo "Downloading CoScribe 2.1.0 for Linux..." curl -fL --progress-bar -o "$TMP/$FILE" "$BASE/$FILE" echo "$SHA $TMP/$FILE" | sha256sum -c - >/dev/null || { echo "Download is corrupt (checksum mismatch). Try again." >&2; exit 1; } chmod +x "$TMP/$FILE" mkdir -p "$APPDIR" "$(dirname "$BIN")" "$(dirname "$DESKTOP")" "$(dirname "$MIMEXML")" "$(dirname "$ICON")" mv -f "$TMP/$FILE" "$APP" # the same app from before it was called CoScribe rm -f "$APPDIR/Engrave.AppImage" "$HOME/.local/bin/engrave" "$DATA/applications/engrave.desktop" "$DATA/mime/packages/engrave.xml" # How to start it here: # - Chromium's sandbox needs user namespaces in an AppImage (the .deb package has a setuid helper instead). # Ubuntu 23.10+ restricts them, and some systems turn them off; then the app only starts with --no-sandbox. # - AppImages mount themselves with FUSE; without libfuse2 they can unpack and run instead (slower start). FLAGS="" ENVS="" if [ "$(cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns 2>/dev/null || echo 0)" = 1 ] || ! unshare -Ur true >/dev/null 2>&1; then FLAGS="--no-sandbox" NOTE_SANDBOX=1 fi if ! { ldconfig -p 2>/dev/null || /sbin/ldconfig -p 2>/dev/null || true; } | grep -q 'libfuse\.so\.2' && ! ls /lib*/libfuse.so.2 /usr/lib*/libfuse.so.2 /lib/*-linux-gnu/libfuse.so.2 /usr/lib/*-linux-gnu/libfuse.so.2 >/dev/null 2>&1; then ENVS="APPIMAGE_EXTRACT_AND_RUN=1 " NOTE_FUSE=1 fi cat > "$BIN" </dev/null 2>&1 && cp "$(ls -S squashfs-root/*.png 2>/dev/null | head -1)" "$ICON" ) 2>/dev/null || true ICON_NAME=coscribe [ -f "$ICON" ] || ICON_NAME=audio-x-generic # MuseScore's file types, in case MuseScore (an AppImage, say) didn't set them up cat > "$MIMEXML" <<'EOF' MuseScore score MuseScore score (uncompressed) CoScribe project EOF cat > "$DESKTOP" </dev/null && { xdg-mime default coscribe.desktop x-scheme-handler/coscribe; xdg-mime default coscribe.desktop application/x-coscribe; } >/dev/null 2>&1 || true echo "Installed CoScribe 2.1.0 to $APP" case ":$PATH:" in *":$HOME/.local/bin:"*) ;; *) echo "Add ~/.local/bin to your PATH to start it with the coscribe command (it is in your app menu either way)." ;; esac [ -n "${NOTE_SANDBOX:-}" ] && echo "Note: this system restricts the sandbox AppImages use, so CoScribe runs without it. The .deb package from the download page keeps it." [ -n "${NOTE_FUSE:-}" ] && echo "Note: libfuse2 isn't installed, so CoScribe unpacks itself on each start (a few seconds). Install libfuse2 (Ubuntu: sudo apt install libfuse2t64) for a quicker start." command -v mscore4portable mscore musescore mscore4 >/dev/null 2>&1 || ls "$HOME"/Applications/MuseScore*.AppImage "$HOME"/Downloads/MuseScore*.AppImage >/dev/null 2>&1 || flatpak info org.musescore.MuseScore >/dev/null 2>&1 || [ -x /snap/bin/musescore ] \ || echo "CoScribe uses MuseScore Studio 4 (free, https://musescore.org/download) to measure and export; install it, or point to it in Settings → MuseScore." if [ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" ]; then nohup "$BIN" >/dev/null 2>&1 & fi