Files
Omarchy-Stream/lib/detect.sh
Levi Woodard a9dcbc1db8 Initial scaffold: idempotent Sunshine + Moonlight installer for Omarchy
Sets up bidirectional game streaming across Omarchy/Hyprland/Wayland
machines (NVIDIA desktop and AMD Framework laptop), with the Macbook
as an additional Moonlight client.

The same install.sh runs on either machine; GPU vendor is detected at
runtime and the appropriate hardware-encode packages are installed.

Includes:
- KMS capture setup (cap_sys_admin on sunshine, input group, uinput udev rule)
- ufw / firewalld port opening when a firewall is active
- systemd --user service + loginctl enable-linger for always-on hosting
- uninstall.sh with --purge for user data removal
- Flags to install host-only or client-only
2026-05-18 10:11:53 -06:00

31 lines
950 B
Bash

#!/usr/bin/env bash
# Detect GPU vendor, session type, hostname.
detect_gpu_vendor() {
local vga
vga="$(lspci -nn 2>/dev/null | grep -iE 'vga|3d|display' || true)"
if grep -qi 'nvidia' <<<"$vga"; then
echo "nvidia"
elif grep -qiE 'amd|advanced micro devices|ati' <<<"$vga"; then
echo "amd"
elif grep -qi 'intel' <<<"$vga"; then
echo "intel"
else
echo "unknown"
fi
}
detect_all() {
HOSTNAME_SHORT="$(hostname -s 2>/dev/null || hostname)"
GPU_VENDOR="$(detect_gpu_vendor)"
SESSION_TYPE="${XDG_SESSION_TYPE:-unknown}"
export HOSTNAME_SHORT GPU_VENDOR SESSION_TYPE
if [[ "$SESSION_TYPE" != "wayland" ]]; then
warn "Session type is '$SESSION_TYPE' (not wayland). KMS capture still works at the TTY/DRM level, but Hyprland-specific paths assume Wayland."
fi
if [[ "$GPU_VENDOR" == "unknown" ]]; then
warn "Could not detect GPU vendor. Encoder packages will be skipped; HW encode may not work."
fi
}