mirror of
https://github.com/merbanan/rtl_433.git
synced 2026-04-21 18:16:58 -04:00
Add XDG_CONFIG_HOME compatability (#954)
This commit is contained in:
committed by
Christian W. Zuckschwerdt
parent
640fc57904
commit
2c7fbd90e9
@@ -12,7 +12,7 @@
|
||||
#
|
||||
# If no -c option is given the first found of this list will be loaded:
|
||||
# - ./rtl_433.conf
|
||||
# - ~/.rtl_433/rtl_433.conf
|
||||
# - ~/.config/rtl_433/rtl_433.conf
|
||||
# - /usr/local/etc/rtl_433.conf
|
||||
# - /etc/rtl_433.conf
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "compat_paths.h"
|
||||
@@ -17,9 +17,13 @@ char **compat_get_default_conf_paths()
|
||||
{
|
||||
static char *paths[5] = { NULL };
|
||||
static char buf[256] = "";
|
||||
char *env_config_home = getenv("XDG_CONFIG_HOME");
|
||||
if (!paths[0]) {
|
||||
paths[0] = "rtl_433.conf";
|
||||
snprintf(buf, sizeof(buf), "%s%s", getenv("HOME"), "/.rtl_433/rtl_433.conf");
|
||||
if (env_config_home && *env_config_home)
|
||||
snprintf(buf, sizeof(buf), "%s%s", env_config_home, "/rtl_433/rtl_433.conf");
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%s%s", getenv("HOME"), "/.config/rtl_433/rtl_433.conf");
|
||||
paths[1] = buf;
|
||||
paths[2] = "/usr/local/etc/rtl_433/rtl_433.conf";
|
||||
paths[3] = "/etc/rtl_433/rtl_433.conf";
|
||||
|
||||
Reference in New Issue
Block a user