#!/usr/sbin/openrc-run

description="ACPI fakekey daemon"

command="/usr/sbin/acpi_fakekeyd"
command_background="yes"

depend() {
	need localmount
}

start_pre() {
	if [ ! -d /sys/devices/virtual/misc/uinput ]; then
		if ! modprobe -q uinput; then
			if ! find "/lib/modules/$(uname -r)" -name 'uinput.*' 2>/dev/null | grep -q uinput; then
				eerror "No suitable uinput module for running kernel found"
				return 1
			fi
			eerror "Modprobe uinput failed. Please use 'dmesg' to find out why"
			return 1
		fi
	fi
	return 0
}
