mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-07-10 00:07:25 -04:00
feat: add load_config_file
This commit is contained in:
parent
581beefef1
commit
c85936dd5e
5 changed files with 16 additions and 5 deletions
|
|
@ -167,6 +167,7 @@ bindr=Super,Super_L,spawn,rofi -show run
|
||||||
| `spawn_shell` | `cmd` | Execute shell command (supports pipes `\|`). |
|
| `spawn_shell` | `cmd` | Execute shell command (supports pipes `\|`). |
|
||||||
| `spawn_on_empty` | `cmd,tagnumber` | Open command on empty tag. |
|
| `spawn_on_empty` | `cmd,tagnumber` | Open command on empty tag. |
|
||||||
| `reload_config` | - | Hot-reload configuration. |
|
| `reload_config` | - | Hot-reload configuration. |
|
||||||
|
| `load_config_file` | `file path` | Load configuration from the specified file. Empty path resets to default config location. |
|
||||||
| `quit` | - | Exit mangowm. |
|
| `quit` | - | Exit mangowm. |
|
||||||
| `toggleoverview` | - | Toggle overview mode. |
|
| `toggleoverview` | - | Toggle overview mode. |
|
||||||
| `togglejump` | - | Toggle overview with jump mode. |
|
| `togglejump` | - | Toggle overview with jump mode. |
|
||||||
|
|
|
||||||
|
|
@ -1190,6 +1190,9 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
||||||
(*arg).i = atoi(arg_value);
|
(*arg).i = atoi(arg_value);
|
||||||
} else if (strcmp(func_name, "reload_config") == 0) {
|
} else if (strcmp(func_name, "reload_config") == 0) {
|
||||||
func = reload_config;
|
func = reload_config;
|
||||||
|
} else if (strcmp(func_name, "load_config_file") == 0) {
|
||||||
|
func = load_config_file;
|
||||||
|
(*arg).v = strdup(arg_value);
|
||||||
} else if (strcmp(func_name, "tag") == 0) {
|
} else if (strcmp(func_name, "tag") == 0) {
|
||||||
func = tag;
|
func = tag;
|
||||||
(*arg).ui = 1 << (atoi(arg_value) - 1);
|
(*arg).ui = 1 << (atoi(arg_value) - 1);
|
||||||
|
|
@ -2994,7 +2997,7 @@ bool parse_config_file(Config *config, const char *file_path, bool must_exist) {
|
||||||
if (file_path[0] == '.' && file_path[1] == '/') {
|
if (file_path[0] == '.' && file_path[1] == '/') {
|
||||||
// Relative path
|
// Relative path
|
||||||
|
|
||||||
if (cli_config_path) {
|
if (cli_config_path[0]) {
|
||||||
char *config_path = strdup(cli_config_path);
|
char *config_path = strdup(cli_config_path);
|
||||||
char *config_dir = dirname(config_path);
|
char *config_dir = dirname(config_path);
|
||||||
snprintf(full_path, sizeof(full_path), "%s/%s", config_dir,
|
snprintf(full_path, sizeof(full_path), "%s/%s", config_dir,
|
||||||
|
|
@ -3868,7 +3871,7 @@ bool parse_config(void) {
|
||||||
|
|
||||||
create_config_keymap();
|
create_config_keymap();
|
||||||
|
|
||||||
if (cli_config_path) {
|
if (cli_config_path[0]) {
|
||||||
snprintf(filename, sizeof(filename), "%s", cli_config_path);
|
snprintf(filename, sizeof(filename), "%s", cli_config_path);
|
||||||
} else {
|
} else {
|
||||||
// 获取当前用户家目录
|
// 获取当前用户家目录
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ int32_t focusstack(const Arg *arg);
|
||||||
int32_t groupfocus(const Arg *arg);
|
int32_t groupfocus(const Arg *arg);
|
||||||
int32_t chvt(const Arg *arg);
|
int32_t chvt(const Arg *arg);
|
||||||
int32_t reload_config(const Arg *arg);
|
int32_t reload_config(const Arg *arg);
|
||||||
|
int32_t load_config_file(const Arg *arg);
|
||||||
int32_t smartmovewin(const Arg *arg);
|
int32_t smartmovewin(const Arg *arg);
|
||||||
int32_t smartresizewin(const Arg *arg);
|
int32_t smartresizewin(const Arg *arg);
|
||||||
int32_t centerwin(const Arg *arg);
|
int32_t centerwin(const Arg *arg);
|
||||||
|
|
|
||||||
|
|
@ -2199,4 +2199,10 @@ int32_t focusid(const Arg *arg) {
|
||||||
|
|
||||||
client_active(c);
|
client_active(c);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t load_config_file(const Arg *arg) {
|
||||||
|
snprintf(cli_config_path, sizeof(cli_config_path), "%s", arg->v);
|
||||||
|
reload_config(arg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1068,7 +1068,7 @@ static struct wl_event_source *hide_cursor_source;
|
||||||
static struct wl_event_source *keep_idle_inhibit_source;
|
static struct wl_event_source *keep_idle_inhibit_source;
|
||||||
static bool cursor_hidden = false;
|
static bool cursor_hidden = false;
|
||||||
static bool tag_combo = false;
|
static bool tag_combo = false;
|
||||||
static const char *cli_config_path = NULL;
|
static char cli_config_path[1024] = {0};
|
||||||
static int active_capture_count = 0;
|
static int active_capture_count = 0;
|
||||||
static bool cli_debug_log = false;
|
static bool cli_debug_log = false;
|
||||||
static KeyMode keymode = {
|
static KeyMode keymode = {
|
||||||
|
|
@ -7383,7 +7383,7 @@ int32_t main(int32_t argc, char *argv[]) {
|
||||||
printf("mango " VERSION "\n");
|
printf("mango " VERSION "\n");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} else if (c == 'c') {
|
} else if (c == 'c') {
|
||||||
cli_config_path = optarg;
|
snprintf(cli_config_path, sizeof(cli_config_path), "%s", optarg);
|
||||||
} else if (c == 'p') {
|
} else if (c == 'p') {
|
||||||
return parse_config() ? EXIT_SUCCESS : EXIT_FAILURE;
|
return parse_config() ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue