feat: install default config.conf to /etc/maomao/config.conf
This commit is contained in:
@@ -86,7 +86,8 @@ mkdir -p ~/.config/maomao/
|
||||
|
||||
|
||||
# config
|
||||
you can use `MAOMAOCONFIG` env to set the config folder path
|
||||
you can use `MAOMAOCONFIG` env to set the config-folder-path and the autostart-folder-patch
|
||||
like `MAOMAOCONFIG=/home/xxx/maomao`
|
||||
|
||||
- the only default keybinds is ctrl+alt+[F1-F12] to change tty
|
||||
|
||||
@@ -94,6 +95,8 @@ you can use `MAOMAOCONFIG` env to set the config folder path
|
||||
|
||||
- the default autostart path is `~/.config/maomao/autostart.sh`
|
||||
|
||||
- the fallback config path is in /etc/maomao/config.conf
|
||||
|
||||
|
||||
# my dotfile
|
||||
[maomao-config](https://github.com/DreamMaoMao/dotfile/tree/main/maomao)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
project('maomao', ['c', 'cpp'],
|
||||
version : '0.1.1'
|
||||
version : '0.1.5'
|
||||
)
|
||||
|
||||
subdir('protocols')
|
||||
@@ -71,3 +71,5 @@ executable('maomao',
|
||||
prefix = get_option('prefix')
|
||||
desktop_install_dir = join_paths(prefix, 'share/wayland-sessions')
|
||||
install_data('maomao.desktop', install_dir : desktop_install_dir)
|
||||
install_data('config.conf', install_dir : '/etc/maomao')
|
||||
|
||||
|
||||
@@ -990,8 +990,8 @@ void parse_config(void) {
|
||||
config.axis_bindings = NULL;
|
||||
config.axis_bindings_count = 0;
|
||||
|
||||
// 获取 MAOMAOCONFIG 环境变量
|
||||
const char *maomaoconfig = getenv("MAOMAOCONFIG");
|
||||
// 获取 MAOMAOCONFIG 环境变量
|
||||
const char *maomaoconfig = getenv("MAOMAOCONFIG");
|
||||
|
||||
// 如果 MAOMAOCONFIG 环境变量不存在或为空,则使用 HOME 环境变量
|
||||
if (!maomaoconfig || maomaoconfig[0] == '\0') {
|
||||
@@ -1003,14 +1003,19 @@ const char *maomaoconfig = getenv("MAOMAOCONFIG");
|
||||
}
|
||||
// 构建日志文件路径
|
||||
snprintf(filename, sizeof(filename), "%s/.config/maomao/config.conf", homedir);
|
||||
|
||||
// 检查文件是否存在
|
||||
if (access(filename, F_OK) != 0) {
|
||||
// 如果文件不存在,则使用 /etc/maomao/config.conf
|
||||
snprintf(filename, sizeof(filename), "/etc/maomao/config.conf");
|
||||
}
|
||||
} else {
|
||||
// 使用 MAOMAOCONFIG 环境变量作为配置文件夹路径
|
||||
snprintf(filename, sizeof(filename), "%s/config.conf", maomaoconfig);
|
||||
}
|
||||
|
||||
set_value_default();
|
||||
parse_config_file(&config, filename);
|
||||
|
||||
set_value_default();
|
||||
parse_config_file(&config, filename);
|
||||
override_config();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user