diff options
Diffstat (limited to 'hosts/mac/kmonad-daemon-shim')
-rw-r--r-- | hosts/mac/kmonad-daemon-shim/default.nix | 18 | ||||
-rw-r--r-- | hosts/mac/kmonad-daemon-shim/main.c | 23 |
2 files changed, 41 insertions, 0 deletions
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 <stdlib.h> +#include <stdio.h> +#include <unistd.h> + +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; + } +} |