Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
```
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build_app_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
153 changes: 153 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion packaging/linux/spacecap.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading
Loading