feat: Add udev rules to meson.build

migrate-to-meson-build
nirenjan 2024-06-13 20:18:35 -07:00
parent 726b5ba21f
commit 0c0a6c1228
2 changed files with 28 additions and 0 deletions

View File

@ -307,3 +307,15 @@ executable('x52ctl', 'daemon/x52ctl.c',
install_data('daemon/x52d.conf',
install_dir: join_paths(get_option('sysconfdir'), 'x52d'))
# udev rules
if dep_udev.found()
udev_rules_dir = join_paths(dep_udev.get_variable('udevdir'), 'rules.d')
udev_file = configure_file(
input: 'udev/60-saitek-x52-x52pro.rules.in',
output: '60-saitek-x52-x52pro.rules',
configuration: {'input_group': 'plugdev'}
)
install_data(udev_file, install_dir: udev_rules_dir)
meson.add_install_script('udev/install-hook.sh')
endif

View File

@ -0,0 +1,16 @@
#!/bin/sh -x
# Run the following command when installing files
# If DESTDIR is not specified or is not /, quit early
if ! test -n "${DESTDIR}" || [ "${DESTDIR}" != "/" ]
then
exit 0
fi
if [ "$(id -u)" = "0" ]
then
udevadm control --reload-rules && \
udevadm trigger --subsystem-match=usb --attr-match=idVendor=06a3 --action=add
fi
true