mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-28 22:23:42 +01:00
1211a81aad
This commit mostly duplicates the wlr_log functions, although with a sway_* prefix. (This is very similar to PR #2009.) However, the logging function no longer needs to be replaceable, so sway_log_init's second argument is used to set the exit callback for sway_abort. wlr_log_init is still invoked in sway/main.c This commit makes it easier to remove the wlroots dependency for the helper programs swaymsg, swaybg, swaybar, and swaynag.
42 lines
1.2 KiB
C
42 lines
1.2 KiB
C
#include <stdlib.h>
|
|
#include <strings.h>
|
|
#include "config.h"
|
|
#include "sway/commands.h"
|
|
#include "sway/config.h"
|
|
#include "log.h"
|
|
|
|
struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) {
|
|
#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;
|
|
}
|
|
|
|
if (!config->current_bar) {
|
|
return cmd_results_new(CMD_FAILURE, "No bar defined.");
|
|
}
|
|
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)) {
|
|
return cmd_results_new(CMD_INVALID,
|
|
"[Bar %s] Invalid tray padding value: %s", bar->id, argv[0]);
|
|
}
|
|
|
|
if (argc == 2 && strcasecmp(argv[1], "px") != 0) {
|
|
return cmd_results_new(CMD_INVALID,
|
|
"Expected 'tray_padding <px> [px]'");
|
|
}
|
|
|
|
sway_log(SWAY_DEBUG, "[Bar %s] Setting tray padding to %d", bar->id, padding);
|
|
config->current_bar->tray_padding = padding;
|
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
|
#else
|
|
return cmd_results_new(CMD_INVALID,
|
|
"Sway has been compiled without tray support");
|
|
#endif
|
|
}
|