#!/bin/bash # ============================================================================ # Install the /wsg/ grabber: system dependencies plus a launcher on PATH. # ============================================================================ set -euo pipefail SCRIPT_NAME="$(basename "$0")" readonly SCRIPT_NAME REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" readonly REPO_ROOT readonly LAUNCHER="/usr/local/bin/wsg-grabber" # mpv provides the player; tk provides the window. Both are runtime-only, and # the package deliberately depends on neither via pip: python-mpv resolves # libmpv at import time and would break any machine without it. readonly PACKAGES=(mpv tk) usage() { echo "Usage: $SCRIPT_NAME [--uninstall]" echo " Installs mpv + tk and a 'wsg-grabber' launcher." exit 0 } require_root() { if [[ $EUID -ne 0 ]]; then echo "Error: needs root to write $LAUNCHER and install packages." >&2 echo "Re-run with: sudo $0" >&2 exit 1 fi } install_packages() { local missing=() local package for package in "${PACKAGES[@]}"; do if ! pacman -Qq "$package" &>/dev/null; then missing+=("$package") fi done if [[ ${#missing[@]} -eq 0 ]]; then echo "System packages already present: ${PACKAGES[*]}" return fi echo "Installing: ${missing[*]}" pacman -S --needed --noconfirm "${missing[@]}" } write_launcher() { cat > "$LAUNCHER" <&2; exit 1 ;; esac