2018-03-29 23:20:03 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <strings.h>
|
2018-12-09 16:10:41 +01:00
|
|
|
#include "config.h"
|
2018-03-29 23:20:03 +02:00
|
|
|
#include "sway/commands.h"
|
2018-12-09 16:10:41 +01:00
|
|
|
#include "sway/config.h"
|
2018-03-29 23:20:03 +02:00
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) {
|
2018-12-09 16:10:41 +01:00
|
|
|
#if HAVE_TRAY
|
|
|
|
struct cmd_results *error = NULL;
|
|
|
|
if ((error = checkarg(argc, "tray_padding", EXPECTED_AT_LEAST, 1))) {
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
if ((error = checkarg(argc, "tray_padding", EXPECTED_AT_MOST, 2))) {
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct bar_config *bar = config->current_bar;
|
|
|
|
|
|
|
|
char *end;
|
|
|
|
int padding = strtol(argv[0], &end, 10);
|
|
|
|
if (padding < 0 || (*end != '\0' && strcasecmp(end, "px") != 0)) {
|
2019-01-11 00:27:21 +01:00
|
|
|
return cmd_results_new(CMD_INVALID,
|
2018-12-09 16:10:41 +01:00
|
|
|
"[Bar %s] Invalid tray padding value: %s", bar->id, argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc == 2 && strcasecmp(argv[1], "px") != 0) {
|
2019-01-11 00:27:21 +01:00
|
|
|
return cmd_results_new(CMD_INVALID,
|
2018-12-09 16:10:41 +01:00
|
|
|
"Expected 'tray_padding <px> [px]'");
|
|
|
|
}
|
|
|
|
|
2019-01-20 19:51:12 +01:00
|
|
|
sway_log(SWAY_DEBUG, "[Bar %s] Setting tray padding to %d", bar->id, padding);
|
2018-12-09 16:10:41 +01:00
|
|
|
config->current_bar->tray_padding = padding;
|
2019-01-11 00:27:21 +01:00
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
2018-12-09 16:10:41 +01:00
|
|
|
#else
|
2019-01-11 00:27:21 +01:00
|
|
|
return cmd_results_new(CMD_INVALID,
|
2018-12-09 16:10:41 +01:00
|
|
|
"Sway has been compiled without tray support");
|
|
|
|
#endif
|
2018-03-29 23:20:03 +02:00
|
|
|
}
|