Skip to content

Commit

Permalink
Load config from executable directory instead of working directory
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
lesderid committed Dec 31, 2022
1 parent f4dd779 commit 27da082
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/keynavish/commands.d
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,14 @@ private void runShellCommand(string shellCommand)

void loadAllConfigs()
{
import std.file : thisExePath;
import std.path : dirName, buildPath;

recordings = [];

foreach (path; configFilePaths)
auto portableConfigPath = dirName(thisExePath()).buildPath("keynavrc");

foreach (path; [portableConfigPath] ~ configFilePaths)
{
loadConfig(path, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/keynavish/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ enum programUrl = "https://github.com/lesderid/keynavish";
enum usageHelpString = "Usage: " ~ programName ~ ".exe [options] [optional-startup-commands]\r\n" ~
"Example: " ~ programName ~ ".exe \"loadconfig ~/myconfigs/keynavrc,loadconfig ~/myconfigs/anotherkeynavrc\"\r\n";

enum configFilePaths = ["keynavrc", "~/.keynavrc", "~/keynavrc", "~/.config/keynav/keynavrc"];
enum configFilePaths = ["~/.keynavrc", "~/keynavrc", "~/.config/keynav/keynavrc"];

enum unhandledExceptionMessage = "This is a bug, please press Ctrl+C and report it at https://github.com/lesderid/keynavish/issues/new.";

0 comments on commit 27da082

Please sign in to comment.