#!/usr/bin/env bash # omarchy-moonlight installer # Sets up Sunshine (host) + Moonlight (client) on Omarchy/Hyprland/Wayland. # Idempotent: re-run safely. Same script works on NVIDIA and AMD machines. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=lib/common.sh source "$SCRIPT_DIR/lib/common.sh" # shellcheck source=lib/detect.sh source "$SCRIPT_DIR/lib/detect.sh" # shellcheck source=lib/preflight.sh source "$SCRIPT_DIR/lib/preflight.sh" # shellcheck source=lib/packages.sh source "$SCRIPT_DIR/lib/packages.sh" # shellcheck source=lib/permissions.sh source "$SCRIPT_DIR/lib/permissions.sh" # shellcheck source=lib/config.sh source "$SCRIPT_DIR/lib/config.sh" # shellcheck source=lib/firewall.sh source "$SCRIPT_DIR/lib/firewall.sh" # shellcheck source=lib/service.sh source "$SCRIPT_DIR/lib/service.sh" # shellcheck source=lib/verify.sh source "$SCRIPT_DIR/lib/verify.sh" # shellcheck source=lib/headless.sh source "$SCRIPT_DIR/lib/headless.sh" # shellcheck source=lib/certs.sh source "$SCRIPT_DIR/lib/certs.sh" usage() { cat < 0 ? 1 : 0 )) fi step "Preflight checks" preflight_all if [[ $INSTALL_SUNSHINE -eq 1 ]]; then step "Installing Sunshine and GPU encoder support" install_sunshine install_gpu_encoder_packages step "Configuring permissions for KMS capture and virtual input" ensure_input_group ensure_uinput_udev_rule set_sunshine_capabilities if [[ "$STREAM_MODE" == "headless" ]]; then step "Installing headless prep-cmd hooks" install_headless_hooks fi if [[ $WRITE_CONFIG -eq 1 ]]; then step "Writing tuned sunshine.conf" write_sunshine_config "$STREAM_MODE" else info "Skipping sunshine.conf (--no-config)" fi if [[ $INSTALL_CERTS -eq 1 ]]; then step "Installing CA-signed Sunshine cert from 1Password" if fetch_and_install_certs; then CERTS_REPLACED=1 else warn "Cert install failed — falling back to Sunshine's self-signed cert." warn "Run scripts/cert-bootstrap.sh to create the CA item, then re-run install.sh." fi else info "Skipping cert step (--no-certs)" fi if [[ $FIREWALL -eq 1 ]]; then step "Configuring firewall for Sunshine ports" open_sunshine_ports else info "Skipping firewall (--no-firewall)" fi if [[ $AUTOSTART -eq 1 ]]; then step "Enabling Sunshine user service" enable_sunshine_service else info "Skipping autostart (--no-autostart). Start manually with: systemctl --user start sunshine" fi else info "Skipping Sunshine install (--no-sunshine)" fi if [[ $INSTALL_MOONLIGHT -eq 1 ]]; then step "Installing Moonlight client" install_moonlight else info "Skipping Moonlight install (--no-moonlight)" fi if [[ $INSTALL_SUNSHINE -eq 1 ]]; then verify_install fi step "Done" print_next_steps } print_next_steps() { local ip ip="$(ip -4 -o addr show scope global | awk '{print $4}' | cut -d/ -f1 | head -n1)" cat <}${RESET} - Enter the 4-digit PIN that Sunshine's UI shows during pairing. 4. To check status: ${DIM}systemctl --user status sunshine${RESET} To view logs: ${DIM}journalctl --user -u sunshine -f${RESET} To uninstall: ${DIM}$SCRIPT_DIR/uninstall.sh${RESET} EOF } main "$@"