aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVerdant <im@verdant.ee>2026-05-17 22:14:01 +0800
committerVerdant <im@verdant.ee>2026-05-17 22:14:01 +0800
commitf2b63eda01b41c82581c08a396ec28b14f14a4ad (patch)
treed852c7dfb3b9c4714486f0fcea9c5a5b0e91e342
parent7b997e7ccfc3b33098868baf6d1835cc69f49fb4 (diff)
downloadkl-f2b63eda01b41c82581c08a396ec28b14f14a4ad.tar.gz
kl-f2b63eda01b41c82581c08a396ec28b14f14a4ad.zip
Modify config API name
enable_time -> time enable_key_counter -> key_counter
-rw-r--r--config.c14
-rw-r--r--main.c10
2 files changed, 13 insertions, 11 deletions
diff --git a/config.c b/config.c
index 2913a4e..19b003d 100644
--- a/config.c
+++ b/config.c
@@ -43,6 +43,8 @@ struct config* prepare_config_file() {
return NULL;
}
fputs(CONFIG_FILE_COMMENT, fp);
+ printf("Config file was generated: %s\n", cfg->config_file_path);
+ printf("Warning: There is no device which is defined in config, see README for details.\n");
fix_config_file_owner(cfg->config_file_path);
printf("%s\n", cfg->config_file_path);
fclose(fp);
@@ -82,17 +84,17 @@ struct config* parese_config(struct config* cfg) {
if (CFG_COMPLETE(key, "device")) {
strncpy(cfg->device, val, sizeof(cfg->device) - 1);
cfg->device[sizeof(cfg->device) - 1] = '\0';
- } else if (CFG_COMPLETE(key, "enable_time")) {
+ } else if (CFG_COMPLETE(key, "time")) {
if (CFG_COMPLETE(val, "true")) {
- cfg->enable_time = true;
+ cfg->time = true;
} else {
- cfg->enable_time = false;
+ cfg->time = false;
}
- } else if (CFG_COMPLETE(key, "enable_key_counter")) {
+ } else if (CFG_COMPLETE(key, "key_counter")) {
if (CFG_COMPLETE(val, "true")) {
- cfg->enable_keys_counter = true;
+ cfg->keys_counter = true;
} else {
- cfg->enable_keys_counter = false;
+ cfg->keys_counter = false;
}
}
}
diff --git a/main.c b/main.c
index e29f192..229e91d 100644
--- a/main.c
+++ b/main.c
@@ -278,29 +278,29 @@ int main(int argc, char ** argv) {
}
if (fd == -1 && errno == ENOENT) {
- printf("No such file or directory: %s\n", cfg -> device);
+ printf("Invalid device, please check your config file.\n");
return -1;
}
init_key_names();
- void( * fp)(struct input_event * ie) = (cfg -> enable_time == true) ? print_with_time : print_pure;
+ void( * fp)(struct input_event * ie) = (cfg -> time == true) ? print_with_time : print_pure;
while (1) {
read(fd, & ie, sizeof(ie));
if (ie.type == EV_KEY) {
if (ie.value == KEY_PRESS) {
- if (line_lock != -1 && !cfg -> enable_time) printf("\n");
+ if (line_lock != -1 && !cfg -> time) printf("\n");
repeat_counters[ie.code] = 1;
line_lock = ie.code;
fp(&ie);
}
if (ie.value == KEY_REPEAT) {
- if (cfg->enable_time) {
- if (cfg->enable_time) printf("\r\033[K");
+ if (cfg->time) {
+ if (cfg->time) printf("\r\033[K");
}
line_lock = ie.code;
repeat_counters[ie.code]++;