Skip to content

Commit

Permalink
Merge pull request input-leap#1892 from sithlord48/patch-1
Browse files Browse the repository at this point in the history
Don't use a hidden file for the config on linux
  • Loading branch information
shymega authored Jun 9, 2024
2 parents 0d6151c + 18eb451 commit fe876ce
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/input-leaps.1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ interfaces using port number 24800.
If no configuration file pathname is provided then the first of the
following to load successfully sets the configuration:
.IP
.I $HOME/.local/share/input-leap/.input-leap.conf
.I $HOME/.config/InputLeap/input-leap.conf
.br
.I /etc/input-leap.conf
.SH COPYRIGHT
Expand Down
4 changes: 2 additions & 2 deletions src/lib/common/unix/DataDirectories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ static fs::path profile_basedir()
#if defined(WINAPI_XWINDOWS) || defined(WINAPI_LIBEI)
// linux/bsd adheres to freedesktop standards
// https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
const char* dir = std::getenv("XDG_DATA_HOME");
const char* dir = std::getenv("XDG_CONFIG_HOME");
if (dir != nullptr)
return fs::u8path(dir);
return unix_home() / ".local/share";
return unix_home() / ".config/";
#else
// macos has its own standards
// https://developer.apple.com/library/content/documentation/General/Conceptual/MOSXAppProgrammingGuide/AppRuntime/AppRuntime.html
Expand Down
8 changes: 4 additions & 4 deletions src/lib/inputleap/ServerApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ ServerApp::help()
profile_path = inputleap::DataDirectories::profile();
}

auto usr_config_path = (profile_path / inputleap::fs::u8path(USR_CONFIG_NAME)).u8string();
auto usr_config_path = (profile_path / inputleap::fs::u8path(CONFIG_NAME)).u8string();
auto sys_config_path = (inputleap::DataDirectories::systemconfig() /
inputleap::fs::u8path(SYS_CONFIG_NAME)).u8string();
inputleap::fs::u8path(CONFIG_NAME)).u8string();

std::ostringstream buffer;
buffer << "Start the InputLeap server component. The server shares the keyboard &\n"
Expand Down Expand Up @@ -208,7 +208,7 @@ ServerApp::loadConfig()
auto path = inputleap::DataDirectories::profile();
if (!path.empty()) {
// complete path
path /= inputleap::fs::u8path(USR_CONFIG_NAME);
path /= inputleap::fs::u8path(CONFIG_NAME);

// now try loading the user's configuration
if (loadConfig(path.u8string())) {
Expand All @@ -220,7 +220,7 @@ ServerApp::loadConfig()
// try the system-wide config file
path = inputleap::DataDirectories::systemconfig();
if (!path.empty()) {
path /= inputleap::fs::u8path(SYS_CONFIG_NAME);
path /= inputleap::fs::u8path(CONFIG_NAME);
if (loadConfig(path.u8string())) {
loaded = true;
args().m_configFile = path.u8string();
Expand Down
6 changes: 2 additions & 4 deletions src/lib/inputleap/ServerApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,9 @@ class ServerApp : public App {

// configuration file name
#if SYSAPI_WIN32
#define USR_CONFIG_NAME "input-leap.sgc"
#define SYS_CONFIG_NAME "input-leap.sgc"
#define CONFIG_NAME "input-leap.sgc"
#elif SYSAPI_UNIX
#define USR_CONFIG_NAME ".input-leap.conf"
#define SYS_CONFIG_NAME "input-leap.conf"
#define CONFIG_NAME "input-leap.conf"
#endif

} // namespace inputleap

0 comments on commit fe876ce

Please sign in to comment.