diff --git a/README.md b/README.md index 676e5c6..302bbc5 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,22 @@ Currently only supports Linux. Still in early development (see roadmap below). ![screenshot2](./docs/screenshot_4.png) +## Install + +**WARNING:** The 'stable' version is still pre-alpha. You may encounter bugs (please +create a new issue). + +```sh +# Install stable version +curl -LsSf https://raw.githubusercontent.com/mgerb/spacecap/main/install.sh | sh + +# Install nightly version (main branch) +curl -LsSf https://raw.githubusercontent.com/mgerb/spacecap/main/install.sh | sh -s -- --nightly + +# Uninstall +curl -LsSf https://raw.githubusercontent.com/mgerb/spacecap/main/install.sh | sh -s -- --uninstall +``` + ## Features - Desktop/window capture. @@ -85,7 +101,7 @@ nix develop -c zig build run -Dnix nix develop -c zig build test -Dnix ``` -### Logging +## Logging By default, Spacecap only writes error logs to `error.log`. Set the `SPACECAP_LOG_LEVEL` environment variable to one of the following to change this @@ -102,3 +118,25 @@ Crash logs are written to `crash.log`. This happens when a panic occurs. - **Linux**: `$XDG_CONFIG_HOME/spacecap`, or `$HOME/.config/spacecap` - **Windows**: `%APPDATA%\spacecap`. + +## Troubleshooting + +### Linux restore capture source stops working + +Spacecap uses the XDG desktop portal screencast permission store to restore the +previous capture source. If the portal permission database gets corrupted, +restore may stop working even after selecting a source again. This has happened +to me after my main disk filled up unexpectedly. + +To reset only the screencast portal permissions, delete the database and then +reboot. + +```sh +# Delete +rm ~/.local/share/flatpak/db/screencast ~/.local/share/flatpak/db/screencast.bak + +# OR move it to a backup +mv ~/.local/share/flatpak/db/screencast ~/.local/share/flatpak/db/screencast.bak + +reboot +``` diff --git a/build.zig.zon b/build.zig.zon index 9a176ee..8ac8644 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -10,7 +10,7 @@ // This is a [Semantic Version](https://semver.org/). // In a future version of Zig it will be used for package deduplication. - .version = "0.3.0", + .version = "0.4.0", // Together with name, this represents a globally unique package // identifier. This field is generated by the Zig toolchain when the diff --git a/build_app_image.sh b/build_app_image.sh index e490cdc..ea8a83e 100755 --- a/build_app_image.sh +++ b/build_app_image.sh @@ -13,7 +13,7 @@ LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}" linuxdeploy \ --appdir AppDir \ --executable zig-out/linux/spacecap \ --desktop-file packaging/linux/spacecap.desktop \ - --icon-file packaging/logo_blue.png \ + --icon-file packaging/spacecap.svg \ --exclude-library libvulkan.so.1 \ --library "$GTK3_LIB" \ --library "$APPINDICATOR_LIB" diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..c724ab0 --- /dev/null +++ b/install.sh @@ -0,0 +1,153 @@ +#!/bin/sh + +set -eu + +APP_NAME="spacecap" +ARTIFACT_NAME="spacecap-linux-x86_64.AppImage" +CHECKSUMS_NAME="SHA256SUMS.txt" +RELEASES_URL="https://github.com/mgerb/spacecap/releases" +RAW_URL="https://raw.githubusercontent.com/mgerb/spacecap/main" +DESKTOP_URL="$RAW_URL/packaging/linux/spacecap.desktop" +ICON_URL="$RAW_URL/packaging/spacecap.svg" +CHANNEL="stable" +MODE="install" + +err() { + echo "Error: $1" >&2 + exit 1 +} + +need_cmd() { + command -v "$1" >/dev/null 2>&1 || err "The required command '$1' was not found." +} + +download() { + url="$1" + dest="$2" + + curl -fL "$url" -o "$dest" +} + +verify_checksum() { + expected="$(awk -v artifact="$ARTIFACT_NAME" '$0 ~ artifact { print $1; found = 1 } END { if (!found) exit 1 }' "$CHECKSUMS_TMP")" \ + || err "The checksum file does not contain $ARTIFACT_NAME." + actual="$(sha256sum "$APPIMAGE_TMP" | awk '{ print $1 }')" + + if [ "$actual" != "$expected" ]; then + err "The checksum for $ARTIFACT_NAME does not match." + fi +} + +for arg in "$@"; do + case "$arg" in + --nightly) + CHANNEL="nightly" + ;; + --uninstall) + MODE="uninstall" + ;; + *) + err "Unknown option: $arg" + ;; + esac +done + +case "$CHANNEL" in + stable) + DOWNLOAD_URL="$RELEASES_URL/latest/download/$ARTIFACT_NAME" + CHECKSUMS_URL="$RELEASES_URL/latest/download/$CHECKSUMS_NAME" + ;; + nightly) + DOWNLOAD_URL="$RELEASES_URL/download/nightly/$ARTIFACT_NAME" + CHECKSUMS_URL="$RELEASES_URL/download/nightly/$CHECKSUMS_NAME" + ;; +esac + +[ -n "${HOME:-}" ] || err "HOME is not set." + +INSTALL_DIR="$HOME/.local/bin" +INSTALL_PATH="$INSTALL_DIR/$APP_NAME" +DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}" +DESKTOP_DIR="$DATA_DIR/applications" +DESKTOP_PATH="$DESKTOP_DIR/$APP_NAME.desktop" +ICON_DIR="$DATA_DIR/icons/hicolor/scalable/apps" +ICON_PATH="$ICON_DIR/$APP_NAME.svg" + +if [ "$MODE" = "uninstall" ]; then + REMOVED=0 + for path in "$INSTALL_PATH" "$DESKTOP_PATH" "$ICON_PATH"; do + if [ -e "$path" ] || [ -L "$path" ]; then + rm -f "$path" + echo "Removed $path." + REMOVED=1 + fi + done + + if [ "$REMOVED" -eq 0 ]; then + echo "$APP_NAME is not installed." + exit 0 + fi + + echo "Uninstalled $APP_NAME." + exit 0 +fi + +if [ "$(uname -s)" != "Linux" ]; then + err "This installer only supports Linux." +fi + +if [ "$(uname -m)" != "x86_64" ]; then + err "This installer only supports Linux x86_64." +fi + +need_cmd curl +need_cmd chmod +need_cmd mkdir +need_cmd mktemp +need_cmd mv +need_cmd rm +need_cmd awk +need_cmd sed +need_cmd sha256sum + +TMP_DIR="$(mktemp -d)" +trap 'rm -rf "$TMP_DIR"' EXIT INT TERM +APPIMAGE_TMP="$TMP_DIR/$ARTIFACT_NAME" +CHECKSUMS_TMP="$TMP_DIR/$CHECKSUMS_NAME" +DESKTOP_TMP="$TMP_DIR/$APP_NAME.desktop" +ICON_TMP="$TMP_DIR/$APP_NAME.svg" + +echo "Downloading $APP_NAME ($CHANNEL) from $DOWNLOAD_URL." +download "$DOWNLOAD_URL" "$APPIMAGE_TMP" + +echo "Downloading checksums." +download "$CHECKSUMS_URL" "$CHECKSUMS_TMP" +verify_checksum + +echo "Downloading the desktop entry." +download "$DESKTOP_URL" "$DESKTOP_TMP" +sed -i "s|^Exec=spacecap$|Exec=$INSTALL_PATH|" "$DESKTOP_TMP" + +echo "Downloading the app icon." +download "$ICON_URL" "$ICON_TMP" + +chmod +x "$APPIMAGE_TMP" +mkdir -p "$INSTALL_DIR" "$DESKTOP_DIR" "$ICON_DIR" +mv "$APPIMAGE_TMP" "$INSTALL_PATH" +mv "$DESKTOP_TMP" "$DESKTOP_PATH" +mv "$ICON_TMP" "$ICON_PATH" + +echo "Installed $APP_NAME to $INSTALL_PATH." +echo "Installed the desktop entry to $DESKTOP_PATH." +echo "Installed the app icon to $ICON_PATH." + +case ":$PATH:" in + *:"$INSTALL_DIR":*) + ;; + *) + echo + echo "$INSTALL_DIR is not on your PATH." + echo "Add it to your shell profile, then restart your shell:" + echo " export PATH=\"$INSTALL_DIR:\$PATH\"" + ;; +esac diff --git a/packaging/linux/spacecap.desktop b/packaging/linux/spacecap.desktop index 46a099f..adc4e00 100644 --- a/packaging/linux/spacecap.desktop +++ b/packaging/linux/spacecap.desktop @@ -3,6 +3,6 @@ Type=Application Name=Spacecap Comment=Hardware accelerated replay capture tool Exec=spacecap -Icon=logo_blue +Icon=spacecap Categories=AudioVideo;Video; Terminal=false diff --git a/packaging/spacecap.svg b/packaging/spacecap.svg new file mode 100644 index 0000000..95fda70 --- /dev/null +++ b/packaging/spacecap.svg @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file