Compare commits
11 Commits
9043844893
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
b0707744e2
|
|||
|
ce2d957a88
|
|||
|
4962f12867
|
|||
|
79a35cf42e
|
|||
|
8a7923bd4e
|
|||
|
a36c82b2ac
|
|||
|
687f9fe715
|
|||
|
488affbe3a
|
|||
|
5d14340f98
|
|||
|
5ddce57fc0
|
|||
|
6c802d0ae4
|
10
build.zig
10
build.zig
@@ -17,11 +17,13 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
var exe = b.addExecutable(.{
|
var exe = b.addExecutable(.{
|
||||||
.name = "zremap",
|
.name = "zremap",
|
||||||
// In this case the main source file is merely a path, however, in more
|
// In this case the main source file is merely a path, however, in more),
|
||||||
// complicated build scripts, this could be a generated file.
|
// complicated build scripts, this could be a generated file.
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
.root_module = b.createModule(.{
|
||||||
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
exe.linkLibC();
|
exe.linkLibC();
|
||||||
exe.linkSystemLibrary("evdev");
|
exe.linkSystemLibrary("evdev");
|
||||||
@@ -57,9 +59,11 @@ pub fn build(b: *std.Build) void {
|
|||||||
// Creates a step for unit testing. This only builds the test executable
|
// Creates a step for unit testing. This only builds the test executable
|
||||||
// but does not run it.
|
// but does not run it.
|
||||||
const unit_tests = b.addTest(.{
|
const unit_tests = b.addTest(.{
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
.root_module = b.createModule(.{
|
||||||
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const run_unit_tests = b.addRunArtifact(unit_tests);
|
const run_unit_tests = b.addRunArtifact(unit_tests);
|
||||||
|
|||||||
6
flake.lock
generated
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1696419054,
|
"lastModified": 1758446476,
|
||||||
"narHash": "sha256-EdR+dIKCfqL3voZUDYwcvgRDOektQB9KbhBVcE0/3Mo=",
|
"narHash": "sha256-5rdAi7CTvM/kSs6fHe1bREIva5W3TbImsto+dxG4mBo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "7131f3c223a2d799568e4b278380cd9dac2b8579",
|
"rev": "a1f79a1770d05af18111fbbe2a3ab2c42c0f6cd0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
28
flake.nix
28
flake.nix
@@ -1,25 +1,35 @@
|
|||||||
{
|
{
|
||||||
description = "zremap nix flake";
|
description = "zremap nix flake";
|
||||||
|
|
||||||
outputs = {
|
outputs =
|
||||||
|
{
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
}: {
|
}:
|
||||||
defaultPackage.x86_64-linux = with import nixpkgs {system = "x86_64-linux";};
|
{
|
||||||
|
defaultPackage.x86_64-linux =
|
||||||
|
with import nixpkgs { system = "x86_64-linux"; };
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = "zremap";
|
pname = "zremap";
|
||||||
version = "0.1";
|
version = "0.2";
|
||||||
src = self;
|
src = self;
|
||||||
nativeBuildInputs = [zig.hook];
|
nativeBuildInputs = [ zig.hook ];
|
||||||
buildInputs = [libevdev pkg-config];
|
buildInputs = [
|
||||||
|
libevdev
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
NIX_CFLAGS_COMPILE="-isystem $(pkg-config --variable=includedir libevdev)/libevdev-1.0 $NIX_CFLAGS_COMPILE"
|
NIX_CFLAGS_COMPILE=" -isystem $(pkg-config --variable=includedir libevdev)/libevdev-1.0 $NIX_CFLAGS_COMPILE"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.x86_64-linux.default = with import nixpkgs {system = "x86_64-linux";};
|
devShells.x86_64-linux.default =
|
||||||
|
with import nixpkgs { system = "x86_64-linux"; };
|
||||||
mkShell {
|
mkShell {
|
||||||
nativeBuildInputs = [zig lldb];
|
nativeBuildInputs = [
|
||||||
|
zig
|
||||||
|
lldb
|
||||||
|
];
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
libevdev
|
libevdev
|
||||||
pkg-config
|
pkg-config
|
||||||
|
|||||||
6
makefile
Normal file
6
makefile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
install:
|
||||||
|
cp ./zremap.service /etc/systemd/system
|
||||||
|
cp ./zremap-start /usr/local/bin
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable zremap.service
|
||||||
@@ -47,10 +47,10 @@ fn uinputWriteKey(uinput_dev: *c.libevdev_uinput, key: u16) !void {
|
|||||||
const pressKey = c.input_event{ .type = c.EV_KEY, .code = key, .value = 1, .time = undefined };
|
const pressKey = c.input_event{ .type = c.EV_KEY, .code = key, .value = 1, .time = undefined };
|
||||||
const releaseKey = c.input_event{ .type = c.EV_KEY, .code = key, .value = 0, .time = undefined };
|
const releaseKey = c.input_event{ .type = c.EV_KEY, .code = key, .value = 0, .time = undefined };
|
||||||
const sync = c.input_event{ .type = c.EV_SYN, .code = c.SYN_REPORT, .value = 0, .time = undefined };
|
const sync = c.input_event{ .type = c.EV_SYN, .code = c.SYN_REPORT, .value = 0, .time = undefined };
|
||||||
std.time.sleep(20000);
|
std.Thread.sleep(20 * std.time.ns_per_ms);
|
||||||
try uinputWrite(uinput_dev, &pressKey);
|
try uinputWrite(uinput_dev, &pressKey);
|
||||||
try uinputWrite(uinput_dev, &sync);
|
try uinputWrite(uinput_dev, &sync);
|
||||||
std.time.sleep(20000);
|
std.Thread.sleep(20 * std.time.ns_per_ms);
|
||||||
try uinputWrite(uinput_dev, &releaseKey);
|
try uinputWrite(uinput_dev, &releaseKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ pub fn main() !void {
|
|||||||
|
|
||||||
if (args.len != 2) {
|
if (args.len != 2) {
|
||||||
std.debug.print("error: expected one argument", .{});
|
std.debug.print("error: expected one argument", .{});
|
||||||
std.os.exit(1);
|
std.posix.exit(1);
|
||||||
}
|
}
|
||||||
const dev_name = args[1];
|
const dev_name = args[1];
|
||||||
const dev = try inputDeviceOpenAndGrab(dev_name);
|
const dev = try inputDeviceOpenAndGrab(dev_name);
|
||||||
|
|||||||
5
zremap-start
Executable file
5
zremap-start
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
sleep 1
|
||||||
|
zremap /dev/input/by-path/platform-i8042-serio-0-event-kbd
|
||||||
|
|
||||||
|
|
||||||
13
zremap.service
Normal file
13
zremap.service
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=zremap keyboard remapping service
|
||||||
|
After=system.slice sysinit.target basic.target systemd-journald.socket
|
||||||
|
Before=shutdown.target multi-user.target
|
||||||
|
StartLimitIntervalSec=0
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=no
|
||||||
|
ExecStart=/usr/local/bin/zremap-start
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Reference in New Issue
Block a user