Merge branch 'master' into popup-during-fullscreen

This commit is contained in:
Brian Ashworth 2018-10-08 15:18:49 -04:00 committed by GitHub
commit 3f328b6276
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 57 additions and 21 deletions

View file

@ -20,6 +20,8 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) {
config->current_bar->status_command = new_command; config->current_bar->status_command = new_command;
wlr_log(WLR_DEBUG, "Feeding bar with status command: %s", wlr_log(WLR_DEBUG, "Feeding bar with status command: %s",
config->current_bar->status_command); config->current_bar->status_command);
} else {
free(new_command);
} }
if (config->active && !config->validating) { if (config->active && !config->validating) {

View file

@ -21,6 +21,10 @@ struct cmd_results *cmd_opacity(int argc, char **argv) {
struct sway_container *con = config->handler_context.container; struct sway_container *con = config->handler_context.container;
if (con == NULL) {
return cmd_results_new(CMD_FAILURE, "opacity", "No current container");
}
float opacity = 0.0f; float opacity = 0.0f;
if (!parse_opacity(argv[0], &opacity)) { if (!parse_opacity(argv[0], &opacity)) {

View file

@ -9,12 +9,17 @@ struct cmd_results *cmd_swaybg_command(int argc, char **argv) {
return error; return error;
} }
if (config->swaybg_command) { free(config->swaybg_command);
free(config->swaybg_command); config->swaybg_command = NULL;
char *new_command = join_args(argv, argc);
if (strcmp(new_command, "-") != 0) {
config->swaybg_command = new_command;
wlr_log(WLR_DEBUG, "Using custom swaybg command: %s",
config->swaybg_command);
} else {
free(new_command);
} }
config->swaybg_command = join_args(argv, argc);
wlr_log(WLR_DEBUG, "Using custom swaybg command: %s",
config->swaybg_command);
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);
} }

View file

@ -9,12 +9,17 @@ struct cmd_results *cmd_swaynag_command(int argc, char **argv) {
return error; return error;
} }
if (config->swaynag_command) { free(config->swaynag_command);
free(config->swaynag_command); config->swaynag_command = NULL;
char *new_command = join_args(argv, argc);
if (strcmp(new_command, "-") != 0) {
config->swaybg_command = new_command;
wlr_log(WLR_DEBUG, "Using custom swaynag command: %s",
config->swaynag_command);
} else {
free(new_command);
} }
config->swaynag_command = join_args(argv, argc);
wlr_log(WLR_DEBUG, "Using custom swaynag command: %s",
config->swaynag_command);
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);
} }

View file

@ -12,6 +12,9 @@ struct cmd_results *cmd_urgent(int argc, char **argv) {
return error; return error;
} }
struct sway_container *container = config->handler_context.container; struct sway_container *container = config->handler_context.container;
if (!container) {
return cmd_results_new(CMD_FAILURE, "urgent", "No current container");
}
if (!container->view) { if (!container->view) {
return cmd_results_new(CMD_INVALID, "urgent", return cmd_results_new(CMD_INVALID, "urgent",
"Only views can be urgent"); "Only views can be urgent");

View file

@ -136,6 +136,8 @@ void free_config(struct sway_config *config) {
free(config->floating_scroll_left_cmd); free(config->floating_scroll_left_cmd);
free(config->floating_scroll_right_cmd); free(config->floating_scroll_right_cmd);
free(config->font); free(config->font);
free(config->swaybg_command);
free(config->swaynag_command);
free((char *)config->current_config_path); free((char *)config->current_config_path);
free((char *)config->current_config); free((char *)config->current_config);
free(config); free(config);
@ -166,7 +168,7 @@ static void set_color(float dest[static 4], uint32_t color) {
} }
static void config_defaults(struct sway_config *config) { static void config_defaults(struct sway_config *config) {
config->swaynag_command = strdup("swaynag"); if (!(config->swaynag_command = strdup("swaynag"))) goto cleanup;
config->swaynag_config_errors = (struct swaynag_instance){ config->swaynag_config_errors = (struct swaynag_instance){
.args = "--type error " .args = "--type error "
"--message 'There are errors in your config file' " "--message 'There are errors in your config file' "
@ -241,6 +243,8 @@ static void config_defaults(struct sway_config *config) {
if (!(config->active_bar_modifiers = create_list())) goto cleanup; if (!(config->active_bar_modifiers = create_list())) goto cleanup;
if (!(config->swaybg_command = strdup("swaybg"))) goto cleanup;
if (!(config->config_chain = create_list())) goto cleanup; if (!(config->config_chain = create_list())) goto cleanup;
config->current_config_path = NULL; config->current_config_path = NULL;
config->current_config = NULL; config->current_config = NULL;

View file

@ -229,17 +229,16 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
} }
} }
if (oc && oc->background) { if (output->bg_pid != 0) {
if (output->bg_pid != 0) { terminate_swaybg(output->bg_pid);
terminate_swaybg(output->bg_pid); }
} if (oc && oc->background && config->swaybg_command) {
wlr_log(WLR_DEBUG, "Setting background for output %d to %s", wlr_log(WLR_DEBUG, "Setting background for output %d to %s",
output_i, oc->background); output_i, oc->background);
size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s", size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s",
config->swaybg_command ? config->swaybg_command : "swaybg", config->swaybg_command, output_i, oc->background,
output_i, oc->background, oc->background_option, oc->background_option,
oc->background_fallback ? oc->background_fallback : ""); oc->background_fallback ? oc->background_fallback : "");
char *command = malloc(len + 1); char *command = malloc(len + 1);
if (!command) { if (!command) {
@ -247,8 +246,8 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
return; return;
} }
snprintf(command, len + 1, "%s %d \"%s\" %s %s", snprintf(command, len + 1, "%s %d \"%s\" %s %s",
config->swaybg_command ? config->swaybg_command : "swaybg", config->swaybg_command, output_i, oc->background,
output_i, oc->background, oc->background_option, oc->background_option,
oc->background_fallback ? oc->background_fallback : ""); oc->background_fallback ? oc->background_fallback : "");
wlr_log(WLR_DEBUG, "-> %s", command); wlr_log(WLR_DEBUG, "-> %s", command);
@ -260,6 +259,7 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
free(command); free(command);
} }
} }
if (oc) { if (oc) {
switch (oc->dpms_state) { switch (oc->dpms_state) {
case DPMS_ON: case DPMS_ON:
@ -353,4 +353,3 @@ void create_default_output_configs(void) {
list_add(config->output_configs, oc); list_add(config->output_configs, oc);
} }
} }

View file

@ -71,6 +71,9 @@ The following commands may only be used in the configuration file.
Executes custom background _command_. Default is _swaybg_. Refer to Executes custom background _command_. Default is _swaybg_. Refer to
*output* below for more information. *output* below for more information.
It can be disabled by setting the command to a single dash:
_swaybg\_command -_
*swaynag\_command* <command> *swaynag\_command* <command>
Executes custom command for _swaynag_. Default is _swaynag_. Additional Executes custom command for _swaynag_. Default is _swaynag_. Additional
arguments may be appended to the end. This should only be used to either arguments may be appended to the end. This should only be used to either
@ -78,6 +81,9 @@ The following commands may only be used in the configuration file.
arguments. This should be placed at the top of the config for the best arguments. This should be placed at the top of the config for the best
results. results.
It can be disabled by setting the command to a single dash:
_swaynag\_command -_
The following commands cannot be used directly in the configuration file. The following commands cannot be used directly in the configuration file.
They are expected to be used with *bindsym* or at runtime through *swaymsg*(1). They are expected to be used with *bindsym* or at runtime through *swaymsg*(1).

View file

@ -11,6 +11,10 @@
bool swaynag_spawn(const char *swaynag_command, bool swaynag_spawn(const char *swaynag_command,
struct swaynag_instance *swaynag) { struct swaynag_instance *swaynag) {
if (!swaynag_command) {
return true;
}
if (swaynag->detailed) { if (swaynag->detailed) {
if (pipe(swaynag->fd) != 0) { if (pipe(swaynag->fd) != 0) {
wlr_log(WLR_ERROR, "Failed to create pipe for swaynag"); wlr_log(WLR_ERROR, "Failed to create pipe for swaynag");
@ -58,6 +62,10 @@ void swaynag_kill(struct swaynag_instance *swaynag) {
void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag, void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag,
const char *fmt, ...) { const char *fmt, ...) {
if (!swaynag_command) {
return;
}
if (!swaynag->detailed) { if (!swaynag->detailed) {
wlr_log(WLR_ERROR, "Attempting to write to non-detailed swaynag inst"); wlr_log(WLR_ERROR, "Attempting to write to non-detailed swaynag inst");
return; return;