mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	add config handlers
This commit is contained in:
		
							parent
							
								
									7262bf655f
								
							
						
					
					
						commit
						2154b7c7d6
					
				
					 2 changed files with 18 additions and 2 deletions
				
			
		| 
						 | 
					@ -138,10 +138,17 @@ static struct cmd_handler handlers[] = {
 | 
				
			||||||
	{ "input", cmd_input },
 | 
						{ "input", cmd_input },
 | 
				
			||||||
	{ "output", cmd_output },
 | 
						{ "output", cmd_output },
 | 
				
			||||||
	{ "seat", cmd_seat },
 | 
						{ "seat", cmd_seat },
 | 
				
			||||||
	{ "set", cmd_set },
 | 
					 | 
				
			||||||
	{ "workspace", cmd_workspace },
 | 
						{ "workspace", cmd_workspace },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Commands that can *only* run in the config loading context
 | 
				
			||||||
 | 
					 * Keep alphabetized
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static struct cmd_handler config_handlers[] = {
 | 
				
			||||||
 | 
						{ "set", cmd_set },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Commands that can *not* run in the config loading context
 | 
					 * Commands that can *not* run in the config loading context
 | 
				
			||||||
 * Keep alphabetized
 | 
					 * Keep alphabetized
 | 
				
			||||||
| 
						 | 
					@ -215,6 +222,16 @@ static struct cmd_handler *find_handler(char *line, enum cmd_status block) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (config->reading) {
 | 
				
			||||||
 | 
							res = bsearch(&d, config_handlers,
 | 
				
			||||||
 | 
									sizeof(config_handlers) / sizeof(struct cmd_handler),
 | 
				
			||||||
 | 
									sizeof(struct cmd_handler), handler_compare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (res) {
 | 
				
			||||||
 | 
								return res;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	res = bsearch(&d, handlers,
 | 
						res = bsearch(&d, handlers,
 | 
				
			||||||
			sizeof(handlers) / sizeof(struct cmd_handler),
 | 
								sizeof(handlers) / sizeof(struct cmd_handler),
 | 
				
			||||||
			sizeof(struct cmd_handler), handler_compare);
 | 
								sizeof(struct cmd_handler), handler_compare);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,6 @@ void free_sway_variable(struct sway_variable *var) {
 | 
				
			||||||
struct cmd_results *cmd_set(int argc, char **argv) {
 | 
					struct cmd_results *cmd_set(int argc, char **argv) {
 | 
				
			||||||
	char *tmp;
 | 
						char *tmp;
 | 
				
			||||||
	struct cmd_results *error = NULL;
 | 
						struct cmd_results *error = NULL;
 | 
				
			||||||
	if (!config->reading) return cmd_results_new(CMD_FAILURE, "set", "Can only be used in config file.");
 | 
					 | 
				
			||||||
	if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) {
 | 
						if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) {
 | 
				
			||||||
		return error;
 | 
							return error;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue