diff --git a/cmake/FindSystemd.cmake b/cmake/FindSystemd.cmake index ee5c70d3e62..74b3d4fce14 100644 --- a/cmake/FindSystemd.cmake +++ b/cmake/FindSystemd.cmake @@ -19,6 +19,11 @@ IF (NOT WIN32) OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE SYSTEMD_USER_UNIT_INSTALL_DIR) + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} + --variable=systemd_user_preset_dir systemd + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE SYSTEMD_USER_PRESET_INSTALL_DIR) + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=systemd_system_unit_dir systemd OUTPUT_STRIP_TRAILING_WHITESPACE @@ -29,7 +34,7 @@ IF (NOT WIN32) OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE SYSTEMD_MODULES_LOAD_DIR) - mark_as_advanced(SYSTEMD_USER_UNIT_INSTALL_DIR SYSTEMD_SYSTEM_UNIT_INSTALL_DIR SYSTEMD_MODULES_LOAD_DIR) + mark_as_advanced(SYSTEMD_USER_UNIT_INSTALL_DIR SYSTEMD_USER_PRESET_INSTALL_DIR SYSTEMD_SYSTEM_UNIT_INSTALL_DIR SYSTEMD_MODULES_LOAD_DIR) endif () diff --git a/cmake/packaging/linux.cmake b/cmake/packaging/linux.cmake index fbdbf13545d..d9538071f14 100644 --- a/cmake/packaging/linux.cmake +++ b/cmake/packaging/linux.cmake @@ -20,6 +20,8 @@ if(${SUNSHINE_BUILD_APPIMAGE} OR ${SUNSHINE_BUILD_FLATPAK}) DESTINATION "${SUNSHINE_ASSETS_DIR}/systemd/user") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine-kms.service" DESTINATION "${SUNSHINE_ASSETS_DIR}/systemd/user") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/00-sunshine-kms.preset" + DESTINATION "${SUNSHINE_ASSETS_DIR}/systemd/user-preset") else() find_package(Systemd) find_package(Udev) @@ -33,6 +35,8 @@ else() DESTINATION "${SYSTEMD_USER_UNIT_INSTALL_DIR}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine-kms.service" DESTINATION "${SYSTEMD_USER_UNIT_INSTALL_DIR}") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/00-sunshine-kms.preset" + DESTINATION "${SYSTEMD_USER_PRESET_INSTALL_DIR}") install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/60-sunshine.conf" DESTINATION "${SYSTEMD_MODULES_LOAD_DIR}") endif() diff --git a/cmake/prep/special_package_configuration.cmake b/cmake/prep/special_package_configuration.cmake index aa19ef38ec0..f7e51d31e4b 100644 --- a/cmake/prep/special_package_configuration.cmake +++ b/cmake/prep/special_package_configuration.cmake @@ -27,6 +27,7 @@ elseif(UNIX) # configure service configure_file(packaging/linux/sunshine.service.in sunshine.service @ONLY) configure_file(packaging/linux/sunshine-kms.service.in sunshine-kms.service @ONLY) + configure_file(packaging/linux/00-sunshine-kms.preset.in 00-sunshine-kms.preset @ONLY) # configure the arch linux pkgbuild if(${SUNSHINE_CONFIGURE_PKGBUILD}) diff --git a/docs/getting_started.md b/docs/getting_started.md index 3ae30abc8d5..3e52cdf9baa 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -274,16 +274,11 @@ flatpak install --user ./sunshine_{arch}.flatpak flatpak run --command=additional-install.sh dev.lizardbyte.app.Sunshine ``` -##### Run with NVFBC capture (X11 Only) +##### Run with NVFBC capture (X11 Only) or XDG Portal (Wayland Only) ```bash flatpak run dev.lizardbyte.app.Sunshine ``` -##### Run with KMS capture (Wayland & X11) -```bash -sudo -i PULSE_SERVER=unix:/run/user/$(id -u $whoami)/pulse/native flatpak run dev.lizardbyte.app.Sunshine -``` - ##### Uninstall ```bash flatpak run --command=remove-additional-install.sh dev.lizardbyte.app.Sunshine @@ -430,9 +425,10 @@ After adding yourself to the group, log out and log back in for the changes to t systemctl --user start sunshine ``` -**Start on boot** +**Start on boot (unprivileged; swap logic for KMS)** ```bash -systemctl --user enable sunshine +systemctl --user --now disable sunshine-kms +systemctl --user --now enable sunshine ``` ### macOS diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 3e4f4503d1f..deacfb5c02e 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -164,14 +164,14 @@ If screencasting fails with KMS, you may be using the unprivileged sunshine serv sunshine-kms service: ```bash -systemctl --user disable sunshine -systemctl --user enable sunshine-kms --now +systemctl --user --now disable sunshine +systemctl --user --now enable sunshine-kms ``` > [!NOTE] -> The above command will not work with the AppImage or Flatpak packages. Please refer to the -> [AppImage setup](md_docs_2getting__started.html#appimage) or -> [Flatpak setup](md_docs_2getting__started.html#flatpak) for more specific instructions. +> The above commands will not work with the AppImage or Flatpak packages, as KMS screencasting +> requires elevated privileges which are not allowed by their respective packaging security policies. +> As an alternative, XDG Portal capture is recommended. ### KMS streaming fails on Nvidia GPUs If KMS screen capture results in a black screen being streamed, you may need to diff --git a/packaging/linux/00-sunshine-kms.preset.in b/packaging/linux/00-sunshine-kms.preset.in new file mode 100644 index 00000000000..5019b8292e9 --- /dev/null +++ b/packaging/linux/00-sunshine-kms.preset.in @@ -0,0 +1,4 @@ +# @PROJECT_DESCRIPTION@ +# KMS service should preset to disabled + +disable sunshine-kms.service diff --git a/packaging/linux/AppImage/AppRun b/packaging/linux/AppImage/AppRun index a0cd5cdf491..c021e425936 100644 --- a/packaging/linux/AppImage/AppRun +++ b/packaging/linux/AppImage/AppRun @@ -58,7 +58,6 @@ function install() { cp -r "$SUNSHINE_SHARE_HERE/systemd/user/" ~/.config/systemd/ # patch service executable path sed -i -e "s#$SUNSHINE_PATH#$(readlink -f $ARGV0)#g" ~/.config/systemd/user/sunshine.service - sed -i -e "s#$SUNSHINE_PATH#$(readlink -f $ARGV0)#g" ~/.config/systemd/user/sunshine-kms.service # setcap sudo setcap cap_sys_admin+p "$(readlink -f "$SUNSHINE_BIN_HERE")" @@ -73,7 +72,6 @@ function remove() { # remove service sudo rm -f ~/.config/systemd/user/sunshine.service - sudo rm -f ~/.config/systemd/user/sunshine-kms.service } # process arguments diff --git a/packaging/linux/copr/Sunshine.spec b/packaging/linux/copr/Sunshine.spec index 01adff0b850..e5476989174 100644 --- a/packaging/linux/copr/Sunshine.spec +++ b/packaging/linux/copr/Sunshine.spec @@ -313,9 +313,10 @@ fi %caps(cap_sys_admin+p) %{_bindir}/sunshine %caps(cap_sys_admin+p) %{_bindir}/sunshine-* -# Systemd unit files for user services +# Systemd unit/preset files for user services %{_userunitdir}/sunshine.service %{_userunitdir}/sunshine-kms.service +%{_userpresetdir}/00-sunshine-kms.preset # Udev rules %{_udevrulesdir}/*-sunshine.rules diff --git a/packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml b/packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml index 6be351690d1..cd5b0815cfe 100644 --- a/packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml +++ b/packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml @@ -33,10 +33,6 @@ flatpak run --command=additional-install.sh @PROJECT_FQDN@

NOTE: Sunshine uses a self-signed certificate. The web browser will report it as not secure, but it is safe.

-

NOTE: KMS Grab (Flatpak)

-

- sudo -i PULSE_SERVER=unix:/run/user/$(id -u $whoami)/pulse/native flatpak run @PROJECT_FQDN@ -

diff --git a/packaging/linux/flatpak/scripts/additional-install.sh b/packaging/linux/flatpak/scripts/additional-install.sh index b1bbba3bce9..5cd6cfbc809 100644 --- a/packaging/linux/flatpak/scripts/additional-install.sh +++ b/packaging/linux/flatpak/scripts/additional-install.sh @@ -3,9 +3,8 @@ # User Service mkdir -p ~/.config/systemd/user cp "/app/share/sunshine/systemd/user/sunshine.service" "$HOME/.config/systemd/user/sunshine.service" -cp "/app/share/sunshine/systemd/user/sunshine-kms.service" "$HOME/.config/systemd/user/sunshine-kms.service" -echo "Sunshine User Services have been installed." -echo "Use [systemctl --user enable sunshine] or [systemctl --user enable sunshine-kms] once to autostart Sunshine on login." +echo "Sunshine User Service has been installed." +echo "Use [systemctl --user enable sunshine] once to autostart Sunshine on login." # Load uhid (DS5 emulation) UHID=$(cat /app/share/sunshine/modules-load.d/60-sunshine.conf) diff --git a/packaging/linux/flatpak/scripts/remove-additional-install.sh b/packaging/linux/flatpak/scripts/remove-additional-install.sh index 6a1a8dfb117..b3b30149bc6 100644 --- a/packaging/linux/flatpak/scripts/remove-additional-install.sh +++ b/packaging/linux/flatpak/scripts/remove-additional-install.sh @@ -3,9 +3,8 @@ # User Service systemctl --user stop sunshine rm "$HOME/.config/systemd/user/sunshine.service" -rm "$HOME/.config/systemd/user/sunshine-kms.service" systemctl --user daemon-reload -echo "Sunshine User Services have been removed." +echo "Sunshine User Service has been removed." # Remove rules flatpak-spawn --host pkexec sh -c "rm /etc/modules-load.d/60-sunshine.conf"