Skip to content

Commit 79cab5e

Browse files
authored
Update show-keybinds.cpp
1 parent b3c7d0a commit 79cab5e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/show-keybinds.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,22 @@ std::string parse_binds(const std::string& filepath, const std::string& category
8181
}
8282

8383
int main() {
84-
const char* home_env = std::getenv("HOME");
85-
if (!home_env) {
86-
std::cerr << "Error: HOME environment variable not set.\n";
87-
return 1;
84+
std::string config_home;
85+
const char* xdg_env = std::getenv("XDG_CONFIG_HOME");
86+
87+
if (xdg_env && *xdg_env != '\0') {
88+
config_home = xdg_env;
89+
} else {
90+
const char* home_env = std::getenv("HOME");
91+
if (!home_env) {
92+
std::cerr << "Error: Neither XDG_CONFIG_HOME nor HOME environment variables are set.\n";
93+
return 1;
94+
}
95+
config_home = std::string(home_env) + "/.config";
8896
}
89-
std::string home(home_env);
9097

91-
std::string core_conf = home + "/.config/hypr/conf.d/08-keybinds.conf";
92-
std::string user_conf = home + "/.config/hypr/user/configs/keybinds.conf";
98+
std::string core_conf = config_home + "/hypr/conf.d/08-keybinds.conf";
99+
std::string user_conf = config_home + "/hypr/user/configs/keybinds.conf";
93100

94101
std::string full_output = parse_binds(core_conf, "SYSTEM CORE BINDS");
95102
full_output += parse_binds(user_conf, "USER OVERRIDES");

0 commit comments

Comments
 (0)