Apply changes to code to support path; Add signal handling; Update README

This commit is contained in:
Allen Wolf
2023-12-30 02:35:32 -06:00
parent 5c3863421b
commit 4973eaaa36
5 changed files with 254 additions and 0 deletions

30
makefile Normal file
View File

@ -0,0 +1,30 @@
# see LICENSE file for copyright and license information.
NAME=mergeinputs
LIBS = -lpthread
SRC = ${NAME}.c
OBJ = ${SRC:.c=.o}
CFLAGS = -Os
DESTDIR = /usr/local
CC=gcc
.c.o:
@echo CC $<
@${CC} -c ${CFLAGS} ${LIBS} $<
${NAME}: ${OBJ}
@echo CC -o $@
@${CC} -o $@ ${OBJ} ${CFLAGS} ${LIBS}
clean:
@echo cleaning
@rm -f ${NAME} *.o
install: ${NAME}
@echo installing executable file to ${DESTDIR}/bin
@mkdir -p ${DESTDIR}/bin
@cp -f ${NAME} ${DESTDIR}/bin/${NAME}
@chmod 755 ${DESTDIR}/bin/${NAME}
uninstall: ${NAME}
@echo removing executable file from ${DESTDIR}/bin
@rm -f ${DESTDIR}/bin/${NAME}

10
mergeinputs-restart.path Normal file
View File

@ -0,0 +1,10 @@
[Path]
Unit=mergeinputs-restart.service
PathChanged=/dev/input/by-path
[Unit]
StartLimitIntervalSec=5
StartLimitBurst=20
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,12 @@
[Unit]
Description=mergeinputs restarter
After=multi-user.target
StartLimitIntervalSec=5
StartLimitBurst=20
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart mergeinputs.service
[Install]
WantedBy=multi-user.target

190
mergeinputs.c Normal file

File diff suppressed because one or more lines are too long

12
mergeinputs.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=Merge multiple keyboards into one input
After=multi-user.target
ConditionPathExistsGlob=/dev/input/by-path/*-kbd
StartLimitIntervalSec=5
StartLimitBurst=20
[Service]
ExecStart=/bin/sh -c '/usr/local/bin/mergeinputs /dev/input/by-path/*-kbd'
[Install]
WantedBy=multi-user.target