Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 0 additions & 14 deletions bin/omarchy-install-service-sunshine
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ SUNSHINE_ADMIN_APP="Sunshine Admin"
SUNSHINE_ADMIN_URL="https://localhost:47990"
SUNSHINE_ADMIN_EXEC="omarchy-launch-webapp $SUNSHINE_ADMIN_URL --ignore-certificate-errors"
SUNSHINE_ICON_SOURCE="/usr/share/sunshine/web/images/logo-sunshine-45.png"
HYPR_AUTOSTART_FILE="$HOME/.config/hypr/autostart.lua"
HYPR_AUTOSTART_ENTRY='o.launch_on_start("sunshine")'

open_ufw_port_for_private_lans() {
local proto="$1"
Expand Down Expand Up @@ -60,15 +58,6 @@ install_admin_webapp() {
omarchy-webapp-install "$SUNSHINE_ADMIN_APP" "$SUNSHINE_ADMIN_URL" "$SUNSHINE_ICON_SOURCE" "$SUNSHINE_ADMIN_EXEC"
}

enable_hyprland_autostart() {
mkdir -p "$(dirname "$HYPR_AUTOSTART_FILE")"
touch "$HYPR_AUTOSTART_FILE"

if ! grep -Fxq "$HYPR_AUTOSTART_ENTRY" "$HYPR_AUTOSTART_FILE"; then
printf '\n%s\n' "$HYPR_AUTOSTART_ENTRY" >>"$HYPR_AUTOSTART_FILE"
fi
}

echo "Installing Sunshine..."
omarchy-pkg-add sunshine
systemctl --user enable --now sunshine
Expand All @@ -80,8 +69,5 @@ echo "Installing Sunshine admin web app..."
install_admin_webapp
$SUNSHINE_ADMIN_EXEC >/dev/null 2>&1 &

echo "Enabling Sunshine autostart..."
enable_hyprland_autostart

echo ""
echo "Sunshine has been installed and its Moonlight streaming ports are open for private LANs and Tailscale."
12 changes: 12 additions & 0 deletions migrations/1789703649.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
echo "Stop starting Sunshine twice at login"

# The installer used to enable the systemd user unit and also append
# o.launch_on_start("sunshine"), so login started two copies and the extra
# process SIGABRTed. Autostart is the user unit alone now; strip the leftover
# Hyprland line from existing installs. Removal already deletes this line.
file="$HOME/.config/hypr/autostart.lua"
entry='o.launch_on_start("sunshine")'

[[ -f $file ]] || exit 0
grep -Fxq "$entry" "$file" || exit 0
sed -i "\|^$entry$|d" "$file"
43 changes: 43 additions & 0 deletions test/shell.d/sunshine-autostart-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

if grep -Fq 'launch_on_start("sunshine")' "$ROOT/bin/omarchy-install-service-sunshine"; then
fail "Sunshine installer does not add a Hyprland autostart copy"
fi
pass "Sunshine installer does not add a Hyprland autostart copy"

grep -Fq 'o.launch_on_start("sunshine")' "$ROOT/bin/omarchy-remove-service-sunshine" ||
fail "Sunshine removal still strips a leftover Hyprland autostart line"
pass "Sunshine removal still strips a leftover Hyprland autostart line"

grep -Fq 'systemctl --user enable --now sunshine' "$ROOT/bin/omarchy-install-service-sunshine" ||
fail "Sunshine still autostarts through the user unit"
pass "Sunshine still autostarts through the user unit"

test_tmp=$(mktemp -d)
trap 'rm -rf "$test_tmp"' EXIT
home="$test_tmp/home"
mkdir -p "$home/.config/hypr"
autostart="$home/.config/hypr/autostart.lua"

cat >"$autostart" <<'LUA'
-- Extra autostart processes.
o.launch_on_start("my-service")
o.launch_on_start("sunshine")
LUA

HOME="$home" bash -euo pipefail "$ROOT/migrations/1789703649.sh" >/dev/null
grep -Fq 'o.launch_on_start("my-service")' "$autostart" ||
fail "Sunshine migration leaves other autostart entries"
if grep -Fq 'o.launch_on_start("sunshine")' "$autostart"; then
fail "Sunshine migration removes the duplicate autostart line"
fi
pass "Sunshine migration removes the duplicate autostart line"

HOME="$home" bash -euo pipefail "$ROOT/migrations/1789703649.sh" >/dev/null
grep -Fq 'o.launch_on_start("my-service")' "$autostart" ||
fail "Sunshine migration is idempotent"
pass "Sunshine migration is idempotent"