Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for config/log/lock file paths customization #18

Closed
foolnotion opened this issue Aug 26, 2021 · 1 comment
Closed

Allow for config/log/lock file paths customization #18

foolnotion opened this issue Aug 26, 2021 · 1 comment

Comments

@foolnotion
Copy link

Hi,

Some distros like Nixos use non-standard paths, so it would be cool if the paths for the config file, log file and lock file could be customized. Currently I've patched the source code & Makefile but obviously another option would be to allow the user to pass these as arguments to the program.

diff --git a/Makefile b/Makefile
index 8f90462..3563b80 100644
--- a/Makefile
+++ b/Makefile
@@ -3,9 +3,13 @@
 DESTDIR=
 PREFIX=/usr
 
+CONFIG_DIR=/etc/keyd
+LOCK_FILE=/var/lock/keyd.lock
+LOG_FILE=/var/log/keyd.log
+
 VERSION=1.1.2
 GIT_HASH=$(shell git describe --no-match --always --abbrev=40 --dirty)
-CFLAGS=-DVERSION=\"$(VERSION)\" -DGIT_COMMIT_HASH=\"$(GIT_HASH)\"
+CFLAGS=-DVERSION=\"$(VERSION)\" -DGIT_COMMIT_HASH=\"$(GIT_HASH)\" -DLOCK_FILE=\"$(LOCK_FILE)\" -DLOG_FILE=\"$(LOG_FILE)\" -DCONFIG_DIR=\"$(CONFIG_DIR)\"
 
 all:
 	mkdir -p bin
diff --git a/src/config.h b/src/config.h
index a6465b8..3a53043 100644
--- a/src/config.h
+++ b/src/config.h
@@ -29,7 +29,11 @@
 #include "keys.h"
 
 #define MAX_LAYERS 32
+
+#ifndef CONFIG_DIR
 #define CONFIG_DIR "/etc/keyd"
+#endif
+
 #define MAX_LAYER_NAME_LEN 256
 #define MAX_MACRO_SIZE 256
 #define MAX_MACROS 256
diff --git a/src/main.c b/src/main.c
index 86dbc7e..a697170 100644
--- a/src/main.c
+++ b/src/main.c
@@ -42,8 +42,14 @@
 
 #define UINPUT_DEVICE_NAME "keyd virtual keyboard"
 #define MAX_KEYBOARDS 256
+
+#ifndef LOCK_FILE
 #define LOCK_FILE "/var/lock/keyd.lock"
+#endif
+
+#ifndef LOG_FILE
 #define LOG_FILE "/var/log/keyd.log" //Only used when running as a daemon.
+#endif
 
 #ifdef DEBUG
 	#define dbg(fmt, ...) warn("%s:%d: "fmt, __FILE__, __LINE__, ## __VA_ARGS__)

Thanks.

@rvaiya
Copy link
Owner

rvaiya commented Aug 27, 2021

I've made them customizable at compile time as above in the latest commit. I'm not sure making them customizable at runtime makes sense though. See #7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants