From e64f7a78e01e5fa661471cb518cc71fc33223b5a Mon Sep 17 00:00:00 2001 From: polwex Date: Sun, 21 Jul 2024 01:49:04 +0700 Subject: m --- hosts/mac/kmonad-daemon-shim/default.nix | 18 ++++++++++++++++++ hosts/mac/kmonad-daemon-shim/main.c | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 hosts/mac/kmonad-daemon-shim/default.nix create mode 100644 hosts/mac/kmonad-daemon-shim/main.c (limited to 'hosts/mac/kmonad-daemon-shim') diff --git a/hosts/mac/kmonad-daemon-shim/default.nix b/hosts/mac/kmonad-daemon-shim/default.nix new file mode 100644 index 0000000..2e53f78 --- /dev/null +++ b/hosts/mac/kmonad-daemon-shim/default.nix @@ -0,0 +1,18 @@ +{ Karabiner-DriverKit-VirtualHIDDevice, stdenv }: + +stdenv.mkDerivation { + pname = "kmonad-daemon-shim"; + version = "0.1.0"; + src = ./.; + patchPhase = '' + substituteInPlace main.c \ + --subst-var-by client "${Karabiner-DriverKit-VirtualHIDDevice}/Library/Application Support/org.pqrs/Karabiner-DriverKit-VirtualHIDDevice/Applications/Karabiner-DriverKit-VirtualHIDDeviceClient.app/Contents/MacOS/Karabiner-DriverKit-VirtualHIDDeviceClient" + ''; + buildPhase = '' + cc main.c -o kmonad-daemon-shim + ''; + installPhase = '' + mkdir -p $out/bin + cp kmonad-daemon-shim $out/bin + ''; +} diff --git a/hosts/mac/kmonad-daemon-shim/main.c b/hosts/mac/kmonad-daemon-shim/main.c new file mode 100644 index 0000000..a9f0596 --- /dev/null +++ b/hosts/mac/kmonad-daemon-shim/main.c @@ -0,0 +1,23 @@ +#include +#include +#include + +char *const kdv_client[] = {"@client@"}; + +int main(int argc, char *argv[]) { + int r = fork(); + if (r < 0) { + perror("kmonad-service-shim: fork"); + return 1; + } else if (r == 0) { + r = execvp(kdv_client[0], kdv_client); + } else { + // To give time for kdv-client to start + sleep(1); + r = execvp("kmonad", argv); + }; + if (r < 0) { + perror("kmonad-service-shim: execvp"); + return 1; + } +} -- cgit v1.2.3