diff --git a/include/sway/commands.h b/include/sway/commands.h index 5210d3ba7..b77f49221 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -125,6 +125,7 @@ sway_cmd cmd_create_output; sway_cmd cmd_default_border; sway_cmd cmd_default_floating_border; sway_cmd cmd_default_orientation; +sway_cmd cmd_env; sway_cmd cmd_exec; sway_cmd cmd_exec_always; sway_cmd cmd_exit; diff --git a/sway/commands.c b/sway/commands.c index c2c12ee65..b07a6a8cf 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -57,6 +57,7 @@ static const struct cmd_handler handlers[] = { { "client.urgent", cmd_client_urgent }, { "default_border", cmd_default_border }, { "default_floating_border", cmd_default_floating_border }, + { "env", cmd_env }, { "exec", cmd_exec }, { "exec_always", cmd_exec_always }, { "floating_maximum_size", cmd_floating_maximum_size }, diff --git a/sway/commands/env.c b/sway/commands/env.c new file mode 100644 index 000000000..2603f257a --- /dev/null +++ b/sway/commands/env.c @@ -0,0 +1,14 @@ +#define _POSIX_C_SOURCE 200809L +#include +#include "sway/commands.h" + +struct cmd_results *cmd_env(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "env", EXPECTED_EQUAL_TO, 2))) { + return error; + } + + setenv(argv[0], argv[1], 1); + + return cmd_results_new(CMD_SUCCESS, NULL); +} diff --git a/sway/meson.build b/sway/meson.build index 8042c89be..ea03e2ef0 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -52,6 +52,7 @@ sway_sources = files( 'commands/default_border.c', 'commands/default_floating_border.c', 'commands/default_orientation.c', + 'commands/env.c', 'commands/exit.c', 'commands/exec.c', 'commands/exec_always.c',