fix: miss apply some config
This commit is contained in:
@@ -33,6 +33,11 @@ typedef struct {
|
|||||||
Arg arg;
|
Arg arg;
|
||||||
} KeyBinding;
|
} KeyBinding;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *type;
|
||||||
|
char *value;
|
||||||
|
} ConfigEnv;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *id;
|
const char *id;
|
||||||
const char *title;
|
const char *title;
|
||||||
@@ -295,6 +300,9 @@ typedef struct {
|
|||||||
GestureBinding *gesture_bindings;
|
GestureBinding *gesture_bindings;
|
||||||
int gesture_bindings_count;
|
int gesture_bindings_count;
|
||||||
|
|
||||||
|
ConfigEnv **env;
|
||||||
|
int env_count;
|
||||||
|
|
||||||
char **exec;
|
char **exec;
|
||||||
int exec_count;
|
int exec_count;
|
||||||
|
|
||||||
@@ -878,6 +886,12 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
|||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_env() {
|
||||||
|
for (int i = 0; i < config.env_count; i++) {
|
||||||
|
setenv(config.env[i]->type, config.env[i]->value, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void run_exec() {
|
void run_exec() {
|
||||||
Arg arg;
|
Arg arg;
|
||||||
|
|
||||||
@@ -1677,7 +1691,23 @@ void parse_config_line(Config *config, const char *line) {
|
|||||||
}
|
}
|
||||||
trim_whitespace(env_type);
|
trim_whitespace(env_type);
|
||||||
trim_whitespace(env_value);
|
trim_whitespace(env_value);
|
||||||
setenv(env_type, env_value, 1);
|
|
||||||
|
ConfigEnv *env = calloc(1, sizeof(ConfigEnv));
|
||||||
|
env->type = strdup(env_type);
|
||||||
|
env->value = strdup(env_value);
|
||||||
|
|
||||||
|
config->env =
|
||||||
|
realloc(config->env, (config->env_count + 1) * sizeof(ConfigEnv));
|
||||||
|
if (!config->env) {
|
||||||
|
free(env->type);
|
||||||
|
free(env->value);
|
||||||
|
free(env);
|
||||||
|
fprintf(stderr, "Error: Failed to allocate memory for env\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
config->env[config->env_count] = env;
|
||||||
|
config->env_count++;
|
||||||
|
|
||||||
} else if (strncmp(key, "exec", 9) == 0) {
|
} else if (strncmp(key, "exec", 9) == 0) {
|
||||||
char **new_exec =
|
char **new_exec =
|
||||||
@@ -2271,6 +2301,22 @@ void free_config(void) {
|
|||||||
config.layer_rules_count = 0;
|
config.layer_rules_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 释放 env
|
||||||
|
if (config.env) {
|
||||||
|
for (int i = 0; i < config.env_count; i++) {
|
||||||
|
if (config.env[i]->type) {
|
||||||
|
free((void *)config.env[i]->type);
|
||||||
|
}
|
||||||
|
if (config.env[i]->value) {
|
||||||
|
free((void *)config.env[i]->value);
|
||||||
|
}
|
||||||
|
free(config.env[i]);
|
||||||
|
}
|
||||||
|
free(config.env);
|
||||||
|
config.env = NULL;
|
||||||
|
config.env_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// 释放 exec
|
// 释放 exec
|
||||||
if (config.exec) {
|
if (config.exec) {
|
||||||
for (i = 0; i < config.exec_count; i++) {
|
for (i = 0; i < config.exec_count; i++) {
|
||||||
@@ -2676,6 +2722,8 @@ void parse_config(void) {
|
|||||||
config.switch_bindings_count = 0;
|
config.switch_bindings_count = 0;
|
||||||
config.gesture_bindings = NULL;
|
config.gesture_bindings = NULL;
|
||||||
config.gesture_bindings_count = 0;
|
config.gesture_bindings_count = 0;
|
||||||
|
config.env = NULL;
|
||||||
|
config.env_count = 0;
|
||||||
config.exec = NULL;
|
config.exec = NULL;
|
||||||
config.exec_count = 0;
|
config.exec_count = 0;
|
||||||
config.exec_once = NULL;
|
config.exec_once = NULL;
|
||||||
@@ -2902,6 +2950,7 @@ void reload_config(const Arg *arg) {
|
|||||||
handlecursoractivity();
|
handlecursoractivity();
|
||||||
reset_keyboard_layout();
|
reset_keyboard_layout();
|
||||||
reset_blur_params();
|
reset_blur_params();
|
||||||
|
set_env();
|
||||||
run_exec();
|
run_exec();
|
||||||
|
|
||||||
reapply_border();
|
reapply_border();
|
||||||
|
|||||||
@@ -4172,6 +4172,9 @@ void exchange_two_client(Client *c1, Client *c2) {
|
|||||||
|
|
||||||
void // 17
|
void // 17
|
||||||
run(char *startup_cmd) {
|
run(char *startup_cmd) {
|
||||||
|
|
||||||
|
set_env();
|
||||||
|
|
||||||
char autostart_temp_path[1024];
|
char autostart_temp_path[1024];
|
||||||
/* Add a Unix socket to the Wayland display. */
|
/* Add a Unix socket to the Wayland display. */
|
||||||
const char *socket = wl_display_add_socket_auto(dpy);
|
const char *socket = wl_display_add_socket_auto(dpy);
|
||||||
@@ -4643,6 +4646,8 @@ void setup(void) {
|
|||||||
|
|
||||||
setenv("XCURSOR_SIZE", "24", 1);
|
setenv("XCURSOR_SIZE", "24", 1);
|
||||||
setenv("XDG_CURRENT_DESKTOP", "mango", 1);
|
setenv("XDG_CURRENT_DESKTOP", "mango", 1);
|
||||||
|
parse_config();
|
||||||
|
init_baked_points();
|
||||||
|
|
||||||
int drm_fd, i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
|
int drm_fd, i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
|
||||||
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig};
|
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig};
|
||||||
@@ -4920,8 +4925,6 @@ void setup(void) {
|
|||||||
"failed to setup XWayland X server, continuing without it\n");
|
"failed to setup XWayland X server, continuing without it\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
parse_config();
|
|
||||||
init_baked_points();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void startdrag(struct wl_listener *listener, void *data) {
|
void startdrag(struct wl_listener *listener, void *data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user