sway/cmd/create_output: Make it possible to set name of new output

`swaymsg create_output new-name-for-output`
This commit is contained in:
Hendrik Wolff 2025-11-04 14:57:06 +01:00
parent 4c75571175
commit 2d335bac57
No known key found for this signature in database
GPG key ID: 9E4B651FC15418E0

View file

@ -1,3 +1,4 @@
#include <strings.h>
#include <wlr/config.h>
#include <wlr/backend/headless.h>
#include <wlr/backend/multi.h>
@ -50,5 +51,17 @@ struct cmd_results *cmd_create_output(int argc, char **argv) {
"Can only create outputs for Wayland, X11 or headless backends");
}
bool should_set_name = argc >= 2 && strcasecmp(argv[0], "name") == 0;
if (should_set_name) {
if (NULL == result.new_output) {
return cmd_results_new(CMD_FAILURE,
"Cannot assign name to new output");
}
sway_log(SWAY_DEBUG, "Set new output name to %s", argv[1]);
wlr_output_set_name(result.new_output, argv[1]);
}
return cmd_results_new(CMD_SUCCESS, NULL);
}