mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 08:21:28 +00:00
Clean up imported bar commands
This commit is contained in:
parent
849c3515ab
commit
741424c4e7
|
@ -3,7 +3,6 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_activate_button(int argc, char **argv) {
|
struct cmd_results *bar_cmd_activate_button(int argc, char **argv) {
|
||||||
const char *cmd_name = "activate_button";
|
|
||||||
// TODO TRAY
|
// TODO TRAY
|
||||||
return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY");
|
return cmd_results_new(CMD_INVALID, "activate_button", "TODO TRAY");
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,23 +5,23 @@
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) {
|
struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if ((error = checkarg(argc, "binding_mode_indicator", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc,
|
||||||
|
"binding_mode_indicator", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "binding_mode_indicator", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE,
|
||||||
|
"binding_mode_indicator", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp("yes", argv[0]) == 0) {
|
if (strcasecmp("yes", argv[0]) == 0) {
|
||||||
config->current_bar->binding_mode_indicator = true;
|
config->current_bar->binding_mode_indicator = true;
|
||||||
wlr_log(L_DEBUG, "Enabling binding mode indicator on bar: %s", config->current_bar->id);
|
wlr_log(L_DEBUG, "Enabling binding mode indicator on bar: %s",
|
||||||
|
config->current_bar->id);
|
||||||
} else if (strcasecmp("no", argv[0]) == 0) {
|
} else if (strcasecmp("no", argv[0]) == 0) {
|
||||||
config->current_bar->binding_mode_indicator = false;
|
config->current_bar->binding_mode_indicator = false;
|
||||||
wlr_log(L_DEBUG, "Disabling binding mode indicator on bar: %s", config->current_bar->id);
|
wlr_log(L_DEBUG, "Disabling binding mode indicator on bar: %s",
|
||||||
} else {
|
config->current_bar->id);
|
||||||
error = cmd_results_new(CMD_INVALID, "binding_mode_indicator", "Invalid value %s", argv[0]);
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_INVALID, "binding_mode_indicator",
|
||||||
|
"Invalid value %s", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +1,38 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
|
|
||||||
static struct cmd_results *parse_single_color(char **color, const char *cmd_name, int argc, char **argv) {
|
static struct cmd_results *parse_single_color(char **color,
|
||||||
|
const char *cmd_name, int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
if (!*color && !(*color = malloc(10))) {
|
||||||
if (!*color) {
|
return NULL;
|
||||||
*color = malloc(10);
|
|
||||||
if (!*color) {
|
|
||||||
return cmd_results_new(CMD_FAILURE, cmd_name, "Unable to allocate color");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
error = add_color(cmd_name, *color, argv[0]);
|
error = add_color(cmd_name, *color, argv[0]);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *parse_three_colors(char ***colors, const char *cmd_name, int argc, char **argv) {
|
static struct cmd_results *parse_three_colors(char ***colors,
|
||||||
|
const char *cmd_name, int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
return cmd_results_new(CMD_INVALID, cmd_name, "Requires exactly three color values");
|
return cmd_results_new(CMD_INVALID,
|
||||||
}
|
cmd_name, "Requires exactly three color values");
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
if (!*colors[i]) {
|
|
||||||
*(colors[i]) = malloc(10);
|
|
||||||
if (!*(colors[i])) {
|
|
||||||
return cmd_results_new(CMD_FAILURE, cmd_name, "Unable to allocate color");
|
|
||||||
}
|
}
|
||||||
|
for (size_t i = 0; i < 3; i++) {
|
||||||
|
if (!*colors[i] && !(*(colors[i]) = malloc(10))) {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
error = add_color(cmd_name, *(colors[i]), argv[i]);
|
error = add_color(cmd_name, *(colors[i]), argv[i]);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,12 +41,10 @@ struct cmd_results *bar_cmd_colors(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "colors", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, "colors", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp("{", argv[0]) != 0) {
|
if (strcmp("{", argv[0]) != 0) {
|
||||||
return cmd_results_new(CMD_INVALID, "colors",
|
return cmd_results_new(CMD_INVALID, "colors",
|
||||||
"Expected '{' at the start of colors config definition.");
|
"Expected '{' at the start of colors config definition.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd_results_new(CMD_BLOCK_BAR_COLORS, NULL, NULL);
|
return cmd_results_new(CMD_BLOCK_BAR_COLORS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,11 +58,13 @@ struct cmd_results *bar_colors_cmd_active_workspace(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_background(int argc, char **argv) {
|
struct cmd_results *bar_colors_cmd_background(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.background), "background", argc, argv);
|
return parse_single_color(&(config->current_bar->colors.background),
|
||||||
|
"background", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_focused_background(int argc, char **argv) {
|
struct cmd_results *bar_colors_cmd_focused_background(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.focused_background), "focused_background", argc, argv);
|
return parse_single_color(&(config->current_bar->colors.focused_background),
|
||||||
|
"focused_background", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_binding_mode(int argc, char **argv) {
|
struct cmd_results *bar_colors_cmd_binding_mode(int argc, char **argv) {
|
||||||
|
@ -104,19 +95,23 @@ struct cmd_results *bar_colors_cmd_inactive_workspace(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_separator(int argc, char **argv) {
|
struct cmd_results *bar_colors_cmd_separator(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.separator), "separator", argc, argv);
|
return parse_single_color(&(config->current_bar->colors.separator),
|
||||||
|
"separator", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_focused_separator(int argc, char **argv) {
|
struct cmd_results *bar_colors_cmd_focused_separator(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.focused_separator), "focused_separator", argc, argv);
|
return parse_single_color(&(config->current_bar->colors.focused_separator),
|
||||||
|
"focused_separator", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_statusline(int argc, char **argv) {
|
struct cmd_results *bar_colors_cmd_statusline(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.statusline), "statusline", argc, argv);
|
return parse_single_color(&(config->current_bar->colors.statusline),
|
||||||
|
"statusline", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_focused_statusline(int argc, char **argv) {
|
struct cmd_results *bar_colors_cmd_focused_statusline(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.focused_separator), "focused_separator", argc, argv);
|
return parse_single_color(&(config->current_bar->colors.focused_separator),
|
||||||
|
"focused_separator", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_urgent_workspace(int argc, char **argv) {
|
struct cmd_results *bar_colors_cmd_urgent_workspace(int argc, char **argv) {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_context_button(int argc, char **argv) {
|
struct cmd_results *bar_cmd_context_button(int argc, char **argv) {
|
||||||
const char *cmd_name = "context_button";
|
|
||||||
// TODO TRAY
|
// TODO TRAY
|
||||||
return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY");
|
return cmd_results_new(CMD_INVALID, "context_button", "TODO TRAY");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
@ -8,19 +9,13 @@ struct cmd_results *bar_cmd_font(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "font", EXPECTED_AT_LEAST, 1))) {
|
if ((error = checkarg(argc, "font", EXPECTED_AT_LEAST, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "font", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE, "font", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
char *font = join_args(argv, argc);
|
char *font = join_args(argv, argc);
|
||||||
free(config->current_bar->font);
|
free(config->current_bar->font);
|
||||||
if (strlen(font) > 6 && strncmp("pango:", font, 6) == 0) {
|
config->current_bar->font = strdup(font);
|
||||||
config->current_bar->font = font;
|
wlr_log(L_DEBUG, "Settings font '%s' for bar: %s",
|
||||||
} else {
|
config->current_bar->font, config->current_bar->id);
|
||||||
config->current_bar->font = font;
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Settings font '%s' for bar: %s", config->current_bar->font, config->current_bar->id);
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,13 @@ struct cmd_results *bar_cmd_height(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "height", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, "height", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int height = atoi(argv[0]);
|
int height = atoi(argv[0]);
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
return cmd_results_new(CMD_INVALID, "height",
|
return cmd_results_new(CMD_INVALID, "height",
|
||||||
"Invalid height value: %s", argv[0]);
|
"Invalid height value: %s", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
config->current_bar->height = height;
|
config->current_bar->height = height;
|
||||||
wlr_log(L_DEBUG, "Setting bar height to %d on bar: %s", height, config->current_bar->id);
|
wlr_log(L_DEBUG, "Setting bar height to %d on bar: %s",
|
||||||
|
height, config->current_bar->id);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ static struct cmd_results *bar_set_hidden_state(struct bar_config *bar,
|
||||||
return cmd_results_new(CMD_INVALID, "hidden_state",
|
return cmd_results_new(CMD_INVALID, "hidden_state",
|
||||||
"Invalid value %s", hidden_state);
|
"Invalid value %s", hidden_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(old_state, bar->hidden_state) != 0) {
|
if (strcmp(old_state, bar->hidden_state) != 0) {
|
||||||
if (!config->reading) {
|
if (!config->reading) {
|
||||||
ipc_event_barconfig_update(bar);
|
ipc_event_barconfig_update(bar);
|
||||||
|
@ -31,7 +30,6 @@ static struct cmd_results *bar_set_hidden_state(struct bar_config *bar,
|
||||||
wlr_log(L_DEBUG, "Setting hidden_state: '%s' for bar: %s",
|
wlr_log(L_DEBUG, "Setting hidden_state: '%s' for bar: %s",
|
||||||
bar->hidden_state, bar->id);
|
bar->hidden_state, bar->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// free old mode
|
// free old mode
|
||||||
free(old_state);
|
free(old_state);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
@ -45,14 +43,12 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "hidden_state", EXPECTED_LESS_THAN, 3))) {
|
if ((error = checkarg(argc, "hidden_state", EXPECTED_LESS_THAN, 3))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->reading && argc > 1) {
|
if (config->reading && argc > 1) {
|
||||||
return cmd_results_new(CMD_INVALID, "hidden_state",
|
return cmd_results_new(CMD_INVALID, "hidden_state",
|
||||||
"Unexpected value %s in config mode", argv[1]);
|
"Unexpected value %s in config mode", argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *state = argv[0];
|
const char *state = argv[0];
|
||||||
|
|
||||||
if (config->reading) {
|
if (config->reading) {
|
||||||
return bar_set_hidden_state(config->current_bar, state);
|
return bar_set_hidden_state(config->current_bar, state);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +57,6 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
id = argv[1];
|
id = argv[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
struct bar_config *bar;
|
struct bar_config *bar;
|
||||||
for (int i = 0; i < config->bars->length; ++i) {
|
for (int i = 0; i < config->bars->length; ++i) {
|
||||||
bar = config->bars->items[i];
|
bar = config->bars->items[i];
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_icon_theme(int argc, char **argv) {
|
struct cmd_results *bar_cmd_icon_theme(int argc, char **argv) {
|
||||||
const char *cmd_name = "tray_output";
|
|
||||||
// TODO TRAY
|
// TODO TRAY
|
||||||
return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY");
|
return cmd_results_new(CMD_INVALID, "icon_theme", "TODO TRAY");
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,8 @@ struct cmd_results *bar_cmd_id(int argc, char **argv) {
|
||||||
|
|
||||||
const char *name = argv[0];
|
const char *name = argv[0];
|
||||||
const char *oldname = config->current_bar->id;
|
const char *oldname = config->current_bar->id;
|
||||||
|
|
||||||
// check if id is used by a previously defined bar
|
// check if id is used by a previously defined bar
|
||||||
int i;
|
for (int i = 0; i < config->bars->length; ++i) {
|
||||||
for (i = 0; i < config->bars->length; ++i) {
|
|
||||||
struct bar_config *find = config->bars->items[i];
|
struct bar_config *find = config->bars->items[i];
|
||||||
if (strcmp(name, find->id) == 0 && config->current_bar != find) {
|
if (strcmp(name, find->id) == 0 && config->current_bar != find) {
|
||||||
return cmd_results_new(CMD_FAILURE, "id",
|
return cmd_results_new(CMD_FAILURE, "id",
|
||||||
|
@ -27,7 +25,6 @@ struct cmd_results *bar_cmd_id(int argc, char **argv) {
|
||||||
|
|
||||||
// free old bar id
|
// free old bar id
|
||||||
free(config->current_bar->id);
|
free(config->current_bar->id);
|
||||||
|
|
||||||
config->current_bar->id = strdup(name);
|
config->current_bar->id = strdup(name);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,13 +44,12 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "mode", EXPECTED_LESS_THAN, 3))) {
|
if ((error = checkarg(argc, "mode", EXPECTED_LESS_THAN, 3))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->reading && argc > 1) {
|
if (config->reading && argc > 1) {
|
||||||
return cmd_results_new(CMD_INVALID, "mode", "Unexpected value %s in config mode", argv[1]);
|
return cmd_results_new(CMD_INVALID,
|
||||||
|
"mode", "Unexpected value %s in config mode", argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *mode = argv[0];
|
const char *mode = argv[0];
|
||||||
|
|
||||||
if (config->reading) {
|
if (config->reading) {
|
||||||
return bar_set_mode(config->current_bar, mode);
|
return bar_set_mode(config->current_bar, mode);
|
||||||
}
|
}
|
||||||
|
@ -60,19 +59,16 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) {
|
||||||
id = argv[1];
|
id = argv[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
|
||||||
struct bar_config *bar;
|
struct bar_config *bar;
|
||||||
for (i = 0; i < config->bars->length; ++i) {
|
for (int i = 0; i < config->bars->length; ++i) {
|
||||||
bar = config->bars->items[i];
|
bar = config->bars->items[i];
|
||||||
if (id && strcmp(id, bar->id) == 0) {
|
if (id && strcmp(id, bar->id) == 0) {
|
||||||
return bar_set_mode(bar, mode);
|
return bar_set_mode(bar, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
error = bar_set_mode(bar, mode);
|
error = bar_set_mode(bar, mode);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t mod = 0;
|
uint32_t mod = 0;
|
||||||
|
|
||||||
list_t *split = split_string(argv[0], "+");
|
list_t *split = split_string(argv[0], "+");
|
||||||
for (int i = 0; i < split->length; ++i) {
|
for (int i = 0; i < split->length; ++i) {
|
||||||
uint32_t tmp_mod;
|
uint32_t tmp_mod;
|
||||||
|
@ -24,12 +23,13 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
free_flat_list(split);
|
free_flat_list(split);
|
||||||
return cmd_results_new(CMD_INVALID, "modifier", "Unknown modifier '%s'", split->items[i]);
|
return cmd_results_new(CMD_INVALID, "modifier",
|
||||||
|
"Unknown modifier '%s'", split->items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free_flat_list(split);
|
free_flat_list(split);
|
||||||
|
|
||||||
config->current_bar->modifier = mod;
|
config->current_bar->modifier = mod;
|
||||||
wlr_log(L_DEBUG, "Show/Hide the bar when pressing '%s' in hide mode.", argv[0]);
|
wlr_log(L_DEBUG,
|
||||||
|
"Show/Hide the bar when pressing '%s' in hide mode.", argv[0]);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#define _XOPEN_SOURCE 500
|
#define _XOPEN_SOURCE 500
|
||||||
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
@ -9,7 +10,6 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "output", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, "output", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "output", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE, "output", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
@ -21,21 +21,20 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) {
|
||||||
config->current_bar->outputs = outputs;
|
config->current_bar->outputs = outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
bool add_output = true;
|
||||||
int add_output = 1;
|
|
||||||
if (strcmp("*", output) == 0) {
|
if (strcmp("*", output) == 0) {
|
||||||
// remove all previous defined outputs and replace with '*'
|
// remove all previous defined outputs and replace with '*'
|
||||||
for (i = 0; i < outputs->length; ++i) {
|
for (int i = 0; i < outputs->length; ++i) {
|
||||||
free(outputs->items[i]);
|
free(outputs->items[i]);
|
||||||
list_del(outputs, i);
|
list_del(outputs, i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// only add output if not already defined with either the same
|
// only add output if not already defined with either the same
|
||||||
// name or as '*'
|
// name or as '*'
|
||||||
for (i = 0; i < outputs->length; ++i) {
|
for (int i = 0; i < outputs->length; ++i) {
|
||||||
const char *find = outputs->items[i];
|
const char *find = outputs->items[i];
|
||||||
if (strcmp("*", find) == 0 || strcmp(output, find) == 0) {
|
if (strcmp("*", find) == 0 || strcmp(output, find) == 0) {
|
||||||
add_output = 0;
|
add_output = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +42,8 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) {
|
||||||
|
|
||||||
if (add_output) {
|
if (add_output) {
|
||||||
list_add(outputs, strdup(output));
|
list_add(outputs, strdup(output));
|
||||||
wlr_log(L_DEBUG, "Adding bar: '%s' to output '%s'", config->current_bar->id, output);
|
wlr_log(L_DEBUG, "Adding bar: '%s' to output '%s'",
|
||||||
|
config->current_bar->id, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,20 @@ struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "pango_markup", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, "pango_markup", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "pango_markup", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE, "pango_markup", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp("enabled", argv[0]) == 0) {
|
if (strcasecmp("enabled", argv[0]) == 0) {
|
||||||
config->current_bar->pango_markup = true;
|
config->current_bar->pango_markup = true;
|
||||||
wlr_log(L_DEBUG, "Enabling pango markup for bar: %s", config->current_bar->id);
|
wlr_log(L_DEBUG, "Enabling pango markup for bar: %s",
|
||||||
|
config->current_bar->id);
|
||||||
} else if (strcasecmp("disabled", argv[0]) == 0) {
|
} else if (strcasecmp("disabled", argv[0]) == 0) {
|
||||||
config->current_bar->pango_markup = false;
|
config->current_bar->pango_markup = false;
|
||||||
wlr_log(L_DEBUG, "Disabling pango markup for bar: %s", config->current_bar->id);
|
wlr_log(L_DEBUG, "Disabling pango markup for bar: %s",
|
||||||
|
config->current_bar->id);
|
||||||
} else {
|
} else {
|
||||||
error = cmd_results_new(CMD_INVALID, "pango_markup", "Invalid value %s", argv[0]);
|
error = cmd_results_new(CMD_INVALID, "pango_markup",
|
||||||
|
"Invalid value %s", argv[0]);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
@ -9,11 +9,9 @@ struct cmd_results *bar_cmd_position(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "position", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE, "position", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
char *valid[] = { "top", "bottom", "left", "right" };
|
char *valid[] = { "top", "bottom", "left", "right" };
|
||||||
for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
|
for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
|
||||||
if (strcasecmp(valid[i], argv[0]) == 0) {
|
if (strcasecmp(valid[i], argv[0]) == 0) {
|
||||||
|
@ -23,7 +21,6 @@ struct cmd_results *bar_cmd_position(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return cmd_results_new(CMD_INVALID,
|
||||||
error = cmd_results_new(CMD_INVALID, "position", "Invalid value %s", argv[0]);
|
"position", "Invalid value %s", argv[0]);
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_secondary_button(int argc, char **argv) {
|
struct cmd_results *bar_cmd_secondary_button(int argc, char **argv) {
|
||||||
const char *cmd_name = "secondary_button";
|
|
||||||
// TODO TRAY
|
// TODO TRAY
|
||||||
return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY");
|
return cmd_results_new(CMD_INVALID, "secondary_button", "TODO TRAY");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,13 @@ struct cmd_results *bar_cmd_separator_symbol(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "separator_symbol", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, "separator_symbol", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "separator_symbol", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE,
|
||||||
|
"separator_symbol", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
free(config->current_bar->separator_symbol);
|
free(config->current_bar->separator_symbol);
|
||||||
config->current_bar->separator_symbol = strdup(argv[0]);
|
config->current_bar->separator_symbol = strdup(argv[0]);
|
||||||
wlr_log(L_DEBUG, "Settings separator_symbol '%s' for bar: %s", config->current_bar->separator_symbol, config->current_bar->id);
|
wlr_log(L_DEBUG, "Settings separator_symbol '%s' for bar: %s",
|
||||||
|
config->current_bar->separator_symbol, config->current_bar->id);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,13 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "status_command", EXPECTED_AT_LEAST, 1))) {
|
if ((error = checkarg(argc, "status_command", EXPECTED_AT_LEAST, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "status_command", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE,
|
||||||
|
"status_command", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
free(config->current_bar->status_command);
|
free(config->current_bar->status_command);
|
||||||
config->current_bar->status_command = join_args(argv, argc);
|
config->current_bar->status_command = join_args(argv, argc);
|
||||||
wlr_log(L_DEBUG, "Feeding bar with status command: %s", config->current_bar->status_command);
|
wlr_log(L_DEBUG, "Feeding bar with status command: %s",
|
||||||
|
config->current_bar->status_command);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,23 +5,25 @@
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) {
|
struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if ((error = checkarg(argc, "strip_workspace_numbers", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc,
|
||||||
|
"strip_workspace_numbers", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "strip_workspace_numbers", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE,
|
||||||
|
"strip_workspace_numbers", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp("yes", argv[0]) == 0) {
|
if (strcasecmp("yes", argv[0]) == 0) {
|
||||||
config->current_bar->strip_workspace_numbers = true;
|
config->current_bar->strip_workspace_numbers = true;
|
||||||
wlr_log(L_DEBUG, "Stripping workspace numbers on bar: %s", config->current_bar->id);
|
wlr_log(L_DEBUG, "Stripping workspace numbers on bar: %s",
|
||||||
|
config->current_bar->id);
|
||||||
} else if (strcasecmp("no", argv[0]) == 0) {
|
} else if (strcasecmp("no", argv[0]) == 0) {
|
||||||
config->current_bar->strip_workspace_numbers = false;
|
config->current_bar->strip_workspace_numbers = false;
|
||||||
wlr_log(L_DEBUG, "Enabling workspace numbers on bar: %s", config->current_bar->id);
|
wlr_log(L_DEBUG, "Enabling workspace numbers on bar: %s",
|
||||||
|
config->current_bar->id);
|
||||||
} else {
|
} else {
|
||||||
error = cmd_results_new(CMD_INVALID, "strip_workspace_numbers", "Invalid value %s", argv[0]);
|
return cmd_results_new(CMD_INVALID,
|
||||||
return error;
|
"strip_workspace_numbers", "Invalid value %s", argv[0]);
|
||||||
}
|
}
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,13 @@ struct cmd_results *bar_cmd_swaybar_command(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "swaybar_command", EXPECTED_AT_LEAST, 1))) {
|
if ((error = checkarg(argc, "swaybar_command", EXPECTED_AT_LEAST, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "swaybar_command", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE,
|
||||||
|
"swaybar_command", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
free(config->current_bar->swaybar_command);
|
free(config->current_bar->swaybar_command);
|
||||||
config->current_bar->swaybar_command = join_args(argv, argc);
|
config->current_bar->swaybar_command = join_args(argv, argc);
|
||||||
wlr_log(L_DEBUG, "Using custom swaybar command: %s", config->current_bar->swaybar_command);
|
wlr_log(L_DEBUG, "Using custom swaybar command: %s",
|
||||||
|
config->current_bar->swaybar_command);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_tray_output(int argc, char **argv) {
|
struct cmd_results *bar_cmd_tray_output(int argc, char **argv) {
|
||||||
const char *cmd_name = "tray_output";
|
|
||||||
// TODO TRAY
|
// TODO TRAY
|
||||||
return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY");
|
return cmd_results_new(CMD_INVALID, "tray_output", "TODO TRAY");
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) {
|
struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) {
|
||||||
const char *cmd_name = "tray_padding";
|
|
||||||
// TODO TRAY
|
// TODO TRAY
|
||||||
return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY");
|
return cmd_results_new(CMD_INVALID, "tray_padding", "TODO TRAY");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,20 +8,21 @@ struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "workspace_buttons", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, "workspace_buttons", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "workspace_buttons", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE,
|
||||||
|
"workspace_buttons", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp("yes", argv[0]) == 0) {
|
if (strcasecmp("yes", argv[0]) == 0) {
|
||||||
config->current_bar->workspace_buttons = true;
|
config->current_bar->workspace_buttons = true;
|
||||||
wlr_log(L_DEBUG, "Enabling workspace buttons on bar: %s", config->current_bar->id);
|
wlr_log(L_DEBUG, "Enabling workspace buttons on bar: %s",
|
||||||
|
config->current_bar->id);
|
||||||
} else if (strcasecmp("no", argv[0]) == 0) {
|
} else if (strcasecmp("no", argv[0]) == 0) {
|
||||||
config->current_bar->workspace_buttons = false;
|
config->current_bar->workspace_buttons = false;
|
||||||
wlr_log(L_DEBUG, "Disabling workspace buttons on bar: %s", config->current_bar->id);
|
wlr_log(L_DEBUG, "Disabling workspace buttons on bar: %s",
|
||||||
|
config->current_bar->id);
|
||||||
} else {
|
} else {
|
||||||
error = cmd_results_new(CMD_INVALID, "workspace_buttons", "Invalid value %s", argv[0]);
|
return cmd_results_new(CMD_INVALID, "workspace_buttons",
|
||||||
return error;
|
"Invalid value %s", argv[0]);
|
||||||
}
|
}
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,20 +8,20 @@ struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) {
|
||||||
if ((error = checkarg(argc, "wrap_scroll", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, "wrap_scroll", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "wrap_scroll", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE, "wrap_scroll", "No bar defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp("yes", argv[0]) == 0) {
|
if (strcasecmp("yes", argv[0]) == 0) {
|
||||||
config->current_bar->wrap_scroll = true;
|
config->current_bar->wrap_scroll = true;
|
||||||
wlr_log(L_DEBUG, "Enabling wrap scroll on bar: %s", config->current_bar->id);
|
wlr_log(L_DEBUG, "Enabling wrap scroll on bar: %s",
|
||||||
|
config->current_bar->id);
|
||||||
} else if (strcasecmp("no", argv[0]) == 0) {
|
} else if (strcasecmp("no", argv[0]) == 0) {
|
||||||
config->current_bar->wrap_scroll = false;
|
config->current_bar->wrap_scroll = false;
|
||||||
wlr_log(L_DEBUG, "Disabling wrap scroll on bar: %s", config->current_bar->id);
|
wlr_log(L_DEBUG, "Disabling wrap scroll on bar: %s",
|
||||||
|
config->current_bar->id);
|
||||||
} else {
|
} else {
|
||||||
error = cmd_results_new(CMD_INVALID, "wrap_scroll", "Invalid value %s", argv[0]);
|
return cmd_results_new(CMD_INVALID,
|
||||||
return error;
|
"wrap_scroll", "Invalid value %s", argv[0]);
|
||||||
}
|
}
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue