diff --git a/cmake/FindSystemd.cmake b/cmake/FindSystemd.cmake index c41ca64d248..c38d62c3f53 100644 --- a/cmake/FindSystemd.cmake +++ b/cmake/FindSystemd.cmake @@ -4,6 +4,7 @@ # SYSTEMD_FOUND - system has systemd # SYSTEMD_USER_UNIT_INSTALL_DIR - the systemd system unit install directory # SYSTEMD_SYSTEM_UNIT_INSTALL_DIR - the systemd user unit install directory +# SYSTEMD_MODULES_LOAD_DIR - the systemd modules-load.d directory IF (NOT WIN32) @@ -15,19 +16,20 @@ IF (NOT WIN32) if (SYSTEMD_FOUND) execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=systemduserunitdir systemd + OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE SYSTEMD_USER_UNIT_INSTALL_DIR) - string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_USER_UNIT_INSTALL_DIR - "${SYSTEMD_USER_UNIT_INSTALL_DIR}") - execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=systemdsystemunitdir systemd + OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE SYSTEMD_SYSTEM_UNIT_INSTALL_DIR) - string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SYSTEM_UNIT_INSTALL_DIR - "${SYSTEMD_SYSTEM_UNIT_INSTALL_DIR}") + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} + --variable=modules_load_dir systemd + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE SYSTEMD_MODULES_LOAD_DIR) - mark_as_advanced(SYSTEMD_USER_UNIT_INSTALL_DIR SYSTEMD_SYSTEM_UNIT_INSTALL_DIR) + mark_as_advanced(SYSTEMD_USER_UNIT_INSTALL_DIR SYSTEMD_SYSTEM_UNIT_INSTALL_DIR SYSTEMD_MODULES_LOAD_DIR) endif () diff --git a/cmake/FindUdev.cmake b/cmake/FindUdev.cmake index 8343f791d35..385c2a00c7e 100644 --- a/cmake/FindUdev.cmake +++ b/cmake/FindUdev.cmake @@ -14,11 +14,9 @@ IF (NOT WIN32) if (UDEV_FOUND) execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=udevdir udev + OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE UDEV_RULES_INSTALL_DIR) - string(REGEX REPLACE "[ \t\n]+" "" UDEV_RULES_INSTALL_DIR - "${UDEV_RULES_INSTALL_DIR}") - set(UDEV_RULES_INSTALL_DIR "${UDEV_RULES_INSTALL_DIR}/rules.d") mark_as_advanced(UDEV_RULES_INSTALL_DIR) diff --git a/cmake/packaging/linux.cmake b/cmake/packaging/linux.cmake index 25f3364c1c4..275b3860ab5 100644 --- a/cmake/packaging/linux.cmake +++ b/cmake/packaging/linux.cmake @@ -8,6 +8,8 @@ file(COPY "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/assets/" if(${SUNSHINE_BUILD_APPIMAGE} OR ${SUNSHINE_BUILD_FLATPAK}) install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/60-sunshine.rules" DESTINATION "${SUNSHINE_ASSETS_DIR}/udev/rules.d") + install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/60-sunshine.conf" + DESTINATION "${SUNSHINE_ASSETS_DIR}/modules-load.d") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service" DESTINATION "${SUNSHINE_ASSETS_DIR}/systemd/user") else() @@ -21,6 +23,8 @@ else() if(SYSTEMD_FOUND) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service" DESTINATION "${SYSTEMD_USER_UNIT_INSTALL_DIR}") + install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/60-sunshine.conf" + DESTINATION "${SYSTEMD_MODULES_LOAD_DIR}") endif() endif() diff --git a/packaging/linux/AppImage/AppRun b/packaging/linux/AppImage/AppRun index 404704c34d3..3c97338c692 100644 --- a/packaging/linux/AppImage/AppRun +++ b/packaging/linux/AppImage/AppRun @@ -47,8 +47,10 @@ function install() { # user input rules # shellcheck disable=SC2002 cat "$SUNSHINE_SHARE_HERE/udev/rules.d/60-sunshine.rules" | sudo tee /etc/udev/rules.d/60-sunshine.rules + cat "$SUNSHINE_SHARE_HERE/modules-load.d/60-sunshine.conf" | sudo tee /etc/modules-load.d/60-sunshine.conf sudo udevadm control --reload-rules sudo udevadm trigger --property-match=DEVNAME=/dev/uinput + sudo modprobe uhid # sunshine service mkdir -p ~/.config/systemd/user @@ -64,6 +66,9 @@ function remove() { # remove input rules sudo rm -f /etc/udev/rules.d/60-sunshine.rules + # remove uhid module loading config + sudo rm -f /etc/modules-load.d/60-sunshine.conf + # remove service sudo rm -f ~/.config/systemd/user/sunshine.service } diff --git a/packaging/linux/Arch/sunshine.install b/packaging/linux/Arch/sunshine.install index a8a700f1f1c..55e739deb16 100644 --- a/packaging/linux/Arch/sunshine.install +++ b/packaging/linux/Arch/sunshine.install @@ -11,10 +11,12 @@ do_udev_reload() { post_install() { do_setcap do_udev_reload + modprobe uhid } post_upgrade() { do_setcap do_udev_reload + modprobe uhid } diff --git a/packaging/linux/flatpak/scripts/additional-install.sh b/packaging/linux/flatpak/scripts/additional-install.sh index a27db4e09ba..d31e2963428 100644 --- a/packaging/linux/flatpak/scripts/additional-install.sh +++ b/packaging/linux/flatpak/scripts/additional-install.sh @@ -6,6 +6,12 @@ cp /app/share/sunshine/systemd/user/sunshine.service $HOME/.config/systemd/user/ 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) +echo "Enabling DS5 emulation." +flatpak-spawn --host pkexec sh -c "echo '$UHID' > /etc/modules-load.d/60-sunshine.conf" +flatpak-spawn --host pkexec modprobe uhid + # Udev rule UDEV=$(cat /app/share/sunshine/udev/rules.d/60-sunshine.rules) echo Configuring mouse permission. diff --git a/packaging/linux/flatpak/scripts/remove-additional-install.sh b/packaging/linux/flatpak/scripts/remove-additional-install.sh index 0d13baeb62c..85e834dc4c5 100644 --- a/packaging/linux/flatpak/scripts/remove-additional-install.sh +++ b/packaging/linux/flatpak/scripts/remove-additional-install.sh @@ -6,6 +6,7 @@ rm $HOME/.config/systemd/user/sunshine.service systemctl --user daemon-reload echo Sunshine User Service has been removed. -# Udev rule +# Remove rules +flatpak-spawn --host pkexec sh -c "rm /etc/modules-load.d/60-sunshine.conf" flatpak-spawn --host pkexec sh -c "rm /etc/udev/rules.d/60-sunshine.rules" echo Mouse permission removed. Restart computer to take effect. diff --git a/src_assets/linux/misc/60-sunshine.conf b/src_assets/linux/misc/60-sunshine.conf new file mode 100644 index 00000000000..779674c5076 --- /dev/null +++ b/src_assets/linux/misc/60-sunshine.conf @@ -0,0 +1,2 @@ +# Sunshine needs uhid for DS5 emulation +uhid diff --git a/src_assets/linux/misc/postinst b/src_assets/linux/misc/postinst index e406c76242f..3df8a837985 100644 --- a/src_assets/linux/misc/postinst +++ b/src_assets/linux/misc/postinst @@ -8,6 +8,9 @@ if [ -x "$path_to_setcap" ] ; then $path_to_setcap cap_sys_admin+p $path_to_sunshine fi +# Load uhid (DS5 emulation) +modprobe uhid + # Trigger udev rule reload for /dev/uinput path_to_udevadm=$(which udevadm) if [ -x "$path_to_udevadm" ] ; then