From 4f12d0a4da72d58f99daa6d4cc9c509fce189caf Mon Sep 17 00:00:00 2001 From: Ella Stanforth Date: Thu, 11 Jul 2024 18:48:52 +0000 Subject: [PATCH] contrib: add example rules script --- Makefile | 4 +++- contrib/libudev-zero-rules-helper.sh | 15 +++++++++++++++ udev_device.c | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100755 contrib/libudev-zero-rules-helper.sh diff --git a/Makefile b/Makefile index 1fc5a1f4..dc201798 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,13 @@ PREFIX = /usr/local LIBDIR = ${PREFIX}/lib +LIBEXECDIR = ${PREFIX}/libexec INCLUDEDIR = ${PREFIX}/include PKGCONFIGDIR = ${LIBDIR}/pkgconfig XCFLAGS = ${CPPFLAGS} ${CFLAGS} -std=c99 -fPIC -D_XOPEN_SOURCE=700 \ -Wall -Wextra -Wpedantic -Wmissing-prototypes -Wstrict-prototypes \ - -Wno-unused-parameter + -Wno-unused-parameter \ + -DRULES_HELPER_PATH=\"${LIBEXECDIR}/libudev-zero-rules-helper\" XLDFLAGS = ${LDFLAGS} -shared -Wl,-soname,libudev.so.1 XARFLAGS = -rc AR = ar diff --git a/contrib/libudev-zero-rules-helper.sh b/contrib/libudev-zero-rules-helper.sh new file mode 100755 index 00000000..2e14a00a --- /dev/null +++ b/contrib/libudev-zero-rules-helper.sh @@ -0,0 +1,15 @@ +#!/bin/sh -e + +if [ "$SUBSYSTEM" = "sound" ] +then + if printf '%s' "$SYSNAME" | grep '^card' > /dev/null + then + printf 'SOUND_INITIALIZED=1\n' + fi + + if printf '%s' "$SYSNAME" | grep '^pcmC.*D2c$' > /dev/null \ + && grep '^AppleJ' "$SYSPATH/device/id" 2>/dev/null + then + printf 'ACP_IGNORE=1\n' + fi +fi diff --git a/udev_device.c b/udev_device.c index a9571261..9cf12255 100644 --- a/udev_device.c +++ b/udev_device.c @@ -55,7 +55,7 @@ #endif #ifndef RULES_HELPER_PATH -#define RULES_HELPER_PATH "/sbin/libudev-zero-rules-helper" +#error "RULES_HELPER_PATH not specified" #endif #ifndef UEVENT_NUM_ENVP