diff options
| author | Caroline Larimore <caroline@larimo.re> | 2025-12-30 17:44:56 -0800 |
|---|---|---|
| committer | Caroline Larimore <caroline@larimo.re> | 2025-12-30 17:44:56 -0800 |
| commit | 54dbcdd211e5da854675655fea1942aae36c52f7 (patch) | |
| tree | 3d8990293e42fec4a08b1dc425f493af9e1f385e | |
| parent | 6f8d02c5360f52b628381c1620248fddbf7a50b1 (diff) | |
feat: allow running as root
| -rw-r--r-- | main.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -210,15 +210,17 @@ void load_mapping() { "MR", "M1", "M2", "M3" }; - char path[256]; - - const char* home = getenv("HOME"); - if (home == NULL) { - printf("$HOME not set, using default mapping"); - return; - }; + char path[256] = "/etc/k95aux/mapping"; + if (geteuid() != 0) { + const char* home = getenv("HOME"); + if (home == NULL) { + printf("$HOME not set, using default mapping"); + return; + }; + + snprintf(path, sizeof(path), "%s/%s", home, ".config/k95aux/mapping"); + } - snprintf(path, sizeof(path), "%s/%s", home, ".config/k95aux/mapping"); FILE *f = fopen(path, "r"); if (f == NULL) { printf("mapping file does not exist, using default mapping"); |