opt: use sysconfigdir to get install path

This commit is contained in:
DreamMaoMao 2025-02-25 13:04:54 +08:00
parent 98413aa01b
commit 28d19fdbc8
2 changed files with 39 additions and 27 deletions

View file

@ -3,6 +3,10 @@
#include <stdint.h>
#include <string.h>
#ifndef SYSCONFDIR
#define SYSCONFDIR "/etc"
#endif
typedef struct {
const char *id;
const char *title;
@ -1024,7 +1028,7 @@ void parse_config(void) {
// 检查文件是否存在
if (access(filename, F_OK) != 0) {
// 如果文件不存在,则使用 /etc/maomao/config.conf
snprintf(filename, sizeof(filename), "/etc/maomao/config.conf");
snprintf(filename, sizeof(filename), "%s/maomao/config.conf",SYSCONFDIR);
}
} else {
// 使用 MAOMAOCONFIG 环境变量作为配置文件夹路径