#!/bin/sh # Load uhid for descriptor-driven gamepad emulation echo "Loading uhid kernel module for gamepad emulation." modprobe uhid # Homebrew installs host integration files inside its Cellar. Copy them to # host directories that systemd-udevd and systemd-modules-load monitor. script_dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd) packaged_udev_rule="$script_dir/../lib/udev/rules.d/60-sunshine.rules" packaged_modules_file="$script_dir/../lib/modules-load.d/60-sunshine.conf" if [ -f "$packaged_udev_rule" ]; then echo "Installing Sunshine udev rules." install -Dm644 "$packaged_udev_rule" /etc/udev/rules.d/60-sunshine.rules fi if [ -f "$packaged_modules_file" ]; then echo "Installing Sunshine modules-load configuration." install -Dm644 "$packaged_modules_file" /etc/modules-load.d/60-sunshine.conf fi # Ensure Sunshine can grab images from KMS path_to_setcap=$(which setcap) if [ -x "$script_dir/sunshine" ]; then path_to_sunshine=$(readlink -f "$script_dir/sunshine") else path_to_sunshine=$(readlink -f "$(which sunshine)") fi if [ -x "$path_to_setcap" ] ; then echo "Setting CAP_SYS_ADMIN, CAP_SYS_NICE capabilities on Sunshine binary." echo "$path_to_setcap cap_sys_admin,cap_sys_nice+p $path_to_sunshine" $path_to_setcap cap_sys_admin,cap_sys_nice+p "$path_to_sunshine" echo "CAP_SYS_ADMIN, CAP_SYS_NICE capabilities set on Sunshine binary." else echo "error: setcap not found or not executable." fi # Reload the rules and reapply them to both virtual device factories and any # gamepad child nodes that already exist. path_to_udevadm=$(which udevadm) if [ -x "$path_to_udevadm" ] ; then echo "Reloading udev rules." $path_to_udevadm control --reload-rules $path_to_udevadm trigger --property-match=DEVNAME=/dev/uinput $path_to_udevadm trigger --property-match=DEVNAME=/dev/uhid $path_to_udevadm trigger --subsystem-match=hidraw $path_to_udevadm trigger --subsystem-match=input echo "Udev rules reloaded successfully." else echo "error: udevadm not found or not executable." fi