From 2718c6679b205446e4162aba82926f724d9d3f35 Mon Sep 17 00:00:00 2001 From: houmain Date: Sun, 28 Jul 2024 20:06:58 +0200 Subject: [PATCH] Look for keymapper.conf in an optional keymapper subdirectory --- README.md | 10 ++++++---- src/client/unix/main.cpp | 4 ++++ src/client/windows/main.cpp | 7 ++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a74ccd7f..31132c11 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,11 @@ Y >> Z Control{Q} >> Alt{F4} ``` -Unless overridden using the command line argument `-c`, the configuration is read from `keymapper.conf`, which is looked for in the common places and in the working directory: - * on Linux and MacOS in `$HOME/.config/` and `/etc/`. - * on Windows in the user's profile, `AppData\Local` and `AppData\Roaming` folders. +Unless overridden using the command line argument `-c`, the configuration is read from `keymapper.conf`, which is looked for in the common places: + * on Linux and MacOS in `$HOME/.config/` and `/etc/` + * on Windows in the user's profile, `AppData\Local` and `AppData\Roaming` folders + +each with an optional `keymapper` subdirectory and finally in the working directory. The command line argument `-u` causes the configuration to be automatically reloaded whenever the configuration file changes. @@ -414,7 +416,7 @@ sudo keymapper-launchd add An installer and a portable build can be downloaded from the [latest release](https://github.com/houmain/keymapper/releases/latest) page. Most conveniently but possibly not always the very latest version can be installed using a package manager: -``` +```bash # install using winget winget install keymapper diff --git a/src/client/unix/main.cpp b/src/client/unix/main.cpp index e01085ed..9b58db8c 100644 --- a/src/client/unix/main.cpp +++ b/src/client/unix/main.cpp @@ -152,6 +152,10 @@ namespace { auto path = base / filename; if (std::filesystem::exists(path, error)) return path; + + path = base / "keymapper" / filename; + if (std::filesystem::exists(path, error)) + return path; } // create in profile path when opening for editing if (!std::filesystem::exists(filename, error)) diff --git a/src/client/windows/main.cpp b/src/client/windows/main.cpp index a7dd3d79..f9aa5042 100644 --- a/src/client/windows/main.cpp +++ b/src/client/windows/main.cpp @@ -266,7 +266,12 @@ namespace { FOLDERID_LocalAppData, FOLDERID_RoamingAppData }) { - auto path = get_known_folder_path(folder_id) / filename; + const auto base = get_known_folder_path(folder_id); + auto path = base / filename; + if (std::filesystem::exists(path, error)) + return path; + + path = base / "keymapper" / filename; if (std::filesystem::exists(path, error)) return path; }