2017-11-23 13:20:41 +11:00
|
|
|
#ifndef _SWAY_COMMANDS_H
|
|
|
|
#define _SWAY_COMMANDS_H
|
|
|
|
|
2018-08-10 14:10:09 +10:00
|
|
|
#include <wlr/util/edges.h>
|
2017-12-11 20:17:14 +11:00
|
|
|
#include "config.h"
|
|
|
|
|
2018-09-23 08:38:15 +10:00
|
|
|
struct sway_container;
|
|
|
|
|
2018-05-31 03:20:02 +10:00
|
|
|
typedef struct cmd_results *sway_cmd(int argc, char **argv);
|
|
|
|
|
|
|
|
struct cmd_handler {
|
|
|
|
char *command;
|
|
|
|
sway_cmd *handle;
|
|
|
|
};
|
|
|
|
|
2017-11-23 13:20:41 +11:00
|
|
|
/**
|
|
|
|
* Indicates the result of a command's execution.
|
|
|
|
*/
|
|
|
|
enum cmd_status {
|
2022-08-22 07:12:54 +10:00
|
|
|
CMD_SUCCESS, /**< The command was successful */
|
2017-11-23 13:20:41 +11:00
|
|
|
CMD_FAILURE, /**< The command resulted in an error */
|
2022-08-22 07:12:54 +10:00
|
|
|
CMD_INVALID, /**< Unknown command or parser error */
|
2017-11-23 13:20:41 +11:00
|
|
|
CMD_DEFER, /**< Command execution deferred */
|
2018-05-31 03:20:02 +10:00
|
|
|
CMD_BLOCK,
|
2017-11-23 13:20:41 +11:00
|
|
|
CMD_BLOCK_COMMANDS,
|
2018-05-31 03:20:02 +10:00
|
|
|
CMD_BLOCK_END
|
2017-11-23 13:20:41 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores the result of executing a command.
|
|
|
|
*/
|
|
|
|
struct cmd_results {
|
|
|
|
enum cmd_status status;
|
|
|
|
/**
|
|
|
|
* Human friendly error message, or NULL on success
|
|
|
|
*/
|
|
|
|
char *error;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum expected_args {
|
|
|
|
EXPECTED_AT_LEAST,
|
2018-10-23 20:40:03 +11:00
|
|
|
EXPECTED_AT_MOST,
|
2017-11-23 13:20:41 +11:00
|
|
|
EXPECTED_EQUAL_TO
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cmd_results *checkarg(int argc, const char *name,
|
|
|
|
enum expected_args type, int val);
|
|
|
|
|
2021-02-03 11:54:35 +11:00
|
|
|
const struct cmd_handler *find_handler(char *line,
|
|
|
|
const struct cmd_handler *cmd_handlers, size_t handlers_size);
|
2019-06-20 08:21:18 +10:00
|
|
|
|
2017-11-23 13:20:41 +11:00
|
|
|
/**
|
2018-02-25 04:50:24 +11:00
|
|
|
* Parse and executes a command.
|
2018-09-23 08:38:15 +10:00
|
|
|
*
|
|
|
|
* If the command string contains criteria then the command will be executed on
|
|
|
|
* all matching containers. Otherwise, it'll run on the `con` container. If
|
|
|
|
* `con` is NULL then it'll run on the currently focused container.
|
2017-11-23 13:20:41 +11:00
|
|
|
*/
|
2018-11-28 13:42:09 +11:00
|
|
|
list_t *execute_command(char *command, struct sway_seat *seat,
|
2018-09-23 08:38:15 +10:00
|
|
|
struct sway_container *con);
|
2017-12-05 20:40:55 +11:00
|
|
|
/**
|
|
|
|
* Parse and handles a command during config file loading.
|
|
|
|
*
|
|
|
|
* Do not use this under normal conditions.
|
|
|
|
*/
|
2019-01-11 00:27:52 +11:00
|
|
|
struct cmd_results *config_command(char *command, char **new_block);
|
2018-05-31 03:20:02 +10:00
|
|
|
/**
|
|
|
|
* Parse and handle a sub command
|
|
|
|
*/
|
2018-05-31 12:23:11 +10:00
|
|
|
struct cmd_results *config_subcommand(char **argv, int argc,
|
2021-02-03 11:54:35 +11:00
|
|
|
const struct cmd_handler *handlers, size_t handlers_size);
|
2017-12-05 20:40:55 +11:00
|
|
|
/*
|
|
|
|
* Parses a command policy rule.
|
|
|
|
*/
|
|
|
|
struct cmd_results *config_commands_command(char *exec);
|
2017-11-23 13:20:41 +11:00
|
|
|
/**
|
|
|
|
* Allocates a cmd_results object.
|
|
|
|
*/
|
2019-01-11 10:27:21 +11:00
|
|
|
struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...);
|
2017-11-23 13:20:41 +11:00
|
|
|
/**
|
|
|
|
* Frees a cmd_results object.
|
|
|
|
*/
|
|
|
|
void free_cmd_results(struct cmd_results *results);
|
|
|
|
/**
|
2018-11-28 13:42:09 +11:00
|
|
|
* Serializes a list of cmd_results to a JSON string.
|
2017-11-23 13:20:41 +11:00
|
|
|
*
|
|
|
|
* Free the JSON string later on.
|
|
|
|
*/
|
2018-11-28 13:42:09 +11:00
|
|
|
char *cmd_results_to_json(list_t *res_list);
|
2017-11-23 13:20:41 +11:00
|
|
|
|
2018-08-10 14:10:09 +10:00
|
|
|
/**
|
|
|
|
* TODO: Move this function and its dependent functions to container.c.
|
|
|
|
*/
|
2019-01-14 22:22:53 +11:00
|
|
|
void container_resize_tiled(struct sway_container *parent, uint32_t axis,
|
2018-08-10 14:10:09 +10:00
|
|
|
int amount);
|
|
|
|
|
2019-01-14 22:22:53 +11:00
|
|
|
struct sway_container *container_find_resize_parent(struct sway_container *con,
|
|
|
|
uint32_t edge);
|
|
|
|
|
2020-08-23 21:59:22 +10:00
|
|
|
/**
|
|
|
|
* Handlers shared by exec and exec_always.
|
|
|
|
*/
|
|
|
|
sway_cmd cmd_exec_validate;
|
|
|
|
sway_cmd cmd_exec_process;
|
|
|
|
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_assign;
|
|
|
|
sway_cmd cmd_bar;
|
|
|
|
sway_cmd cmd_bindcode;
|
2019-03-20 14:47:29 +11:00
|
|
|
sway_cmd cmd_bindswitch;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_bindsym;
|
|
|
|
sway_cmd cmd_border;
|
2018-10-08 05:44:37 +11:00
|
|
|
sway_cmd cmd_client_noop;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_client_focused;
|
|
|
|
sway_cmd cmd_client_focused_inactive;
|
2021-12-11 02:09:29 +11:00
|
|
|
sway_cmd cmd_client_focused_tab_title;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_client_unfocused;
|
|
|
|
sway_cmd cmd_client_urgent;
|
|
|
|
sway_cmd cmd_client_placeholder;
|
|
|
|
sway_cmd cmd_client_background;
|
|
|
|
sway_cmd cmd_commands;
|
2022-08-22 07:12:54 +10:00
|
|
|
sway_cmd cmd_corner_radius;
|
2018-09-19 21:54:27 +10:00
|
|
|
sway_cmd cmd_create_output;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_default_border;
|
|
|
|
sway_cmd cmd_default_floating_border;
|
2018-03-31 01:43:55 +11:00
|
|
|
sway_cmd cmd_default_orientation;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_exec;
|
|
|
|
sway_cmd cmd_exec_always;
|
|
|
|
sway_cmd cmd_exit;
|
|
|
|
sway_cmd cmd_floating;
|
|
|
|
sway_cmd cmd_floating_maximum_size;
|
|
|
|
sway_cmd cmd_floating_minimum_size;
|
2018-07-18 16:13:28 +10:00
|
|
|
sway_cmd cmd_floating_modifier;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_floating_scroll;
|
|
|
|
sway_cmd cmd_focus;
|
|
|
|
sway_cmd cmd_focus_follows_mouse;
|
2018-09-02 15:03:58 +10:00
|
|
|
sway_cmd cmd_focus_on_window_activation;
|
2018-05-28 13:20:21 +10:00
|
|
|
sway_cmd cmd_focus_wrapping;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_font;
|
|
|
|
sway_cmd cmd_for_window;
|
2018-07-20 19:37:27 +10:00
|
|
|
sway_cmd cmd_force_display_urgency_hint;
|
2018-05-29 01:09:46 +10:00
|
|
|
sway_cmd cmd_force_focus_wrapping;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_fullscreen;
|
|
|
|
sway_cmd cmd_gaps;
|
|
|
|
sway_cmd cmd_hide_edge_borders;
|
|
|
|
sway_cmd cmd_include;
|
2019-03-25 12:21:24 +11:00
|
|
|
sway_cmd cmd_inhibit_idle;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_input;
|
2017-12-15 03:11:56 +11:00
|
|
|
sway_cmd cmd_seat;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_ipc;
|
|
|
|
sway_cmd cmd_kill;
|
|
|
|
sway_cmd cmd_layout;
|
|
|
|
sway_cmd cmd_log_colors;
|
|
|
|
sway_cmd cmd_mark;
|
2019-09-26 00:35:41 +10:00
|
|
|
sway_cmd cmd_max_render_time;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_mode;
|
|
|
|
sway_cmd cmd_mouse_warping;
|
|
|
|
sway_cmd cmd_move;
|
2019-04-15 10:16:35 +10:00
|
|
|
sway_cmd cmd_new_float;
|
|
|
|
sway_cmd cmd_new_window;
|
2018-08-07 20:25:04 +10:00
|
|
|
sway_cmd cmd_nop;
|
2018-04-03 14:47:45 +10:00
|
|
|
sway_cmd cmd_opacity;
|
2022-11-12 11:38:09 +11:00
|
|
|
sway_cmd cmd_saturation;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_new_float;
|
|
|
|
sway_cmd cmd_new_window;
|
|
|
|
sway_cmd cmd_no_focus;
|
|
|
|
sway_cmd cmd_output;
|
|
|
|
sway_cmd cmd_permit;
|
2018-10-07 21:40:05 +11:00
|
|
|
sway_cmd cmd_popup_during_fullscreen;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_reject;
|
|
|
|
sway_cmd cmd_reload;
|
2018-04-23 13:04:16 +10:00
|
|
|
sway_cmd cmd_rename;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_resize;
|
|
|
|
sway_cmd cmd_scratchpad;
|
|
|
|
sway_cmd cmd_seamless_mouse;
|
|
|
|
sway_cmd cmd_set;
|
2020-03-13 08:10:04 +11:00
|
|
|
sway_cmd cmd_shortcuts_inhibitor;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_show_marks;
|
2018-10-02 02:56:27 +10:00
|
|
|
sway_cmd cmd_smart_borders;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_smart_gaps;
|
|
|
|
sway_cmd cmd_split;
|
|
|
|
sway_cmd cmd_splith;
|
|
|
|
sway_cmd cmd_splitt;
|
|
|
|
sway_cmd cmd_splitv;
|
|
|
|
sway_cmd cmd_sticky;
|
2018-03-30 08:49:44 +11:00
|
|
|
sway_cmd cmd_swaybg_command;
|
2018-08-03 11:37:29 +10:00
|
|
|
sway_cmd cmd_swaynag_command;
|
2018-05-27 01:02:21 +10:00
|
|
|
sway_cmd cmd_swap;
|
2018-09-11 17:17:19 +10:00
|
|
|
sway_cmd cmd_tiling_drag;
|
2019-01-02 00:45:21 +11:00
|
|
|
sway_cmd cmd_tiling_drag_threshold;
|
2018-11-26 14:08:58 +11:00
|
|
|
sway_cmd cmd_title_align;
|
2018-05-05 12:36:50 +10:00
|
|
|
sway_cmd cmd_title_format;
|
2018-11-18 06:06:48 +11:00
|
|
|
sway_cmd cmd_titlebar_border_thickness;
|
|
|
|
sway_cmd cmd_titlebar_padding;
|
2019-04-13 02:26:23 +10:00
|
|
|
sway_cmd cmd_unbindcode;
|
2019-04-13 02:28:48 +10:00
|
|
|
sway_cmd cmd_unbindswitch;
|
2019-04-13 02:26:23 +10:00
|
|
|
sway_cmd cmd_unbindsym;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_unmark;
|
2018-07-15 22:43:33 +10:00
|
|
|
sway_cmd cmd_urgent;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_workspace;
|
|
|
|
sway_cmd cmd_workspace_layout;
|
2018-11-17 22:29:59 +11:00
|
|
|
sway_cmd cmd_ws_auto_back_and_forth;
|
|
|
|
sway_cmd cmd_xwayland;
|
2017-11-23 13:20:41 +11:00
|
|
|
|
2019-01-11 04:43:10 +11:00
|
|
|
sway_cmd bar_cmd_bindcode;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd bar_cmd_binding_mode_indicator;
|
|
|
|
sway_cmd bar_cmd_bindsym;
|
|
|
|
sway_cmd bar_cmd_colors;
|
|
|
|
sway_cmd bar_cmd_font;
|
2018-11-29 03:23:48 +11:00
|
|
|
sway_cmd bar_cmd_gaps;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd bar_cmd_mode;
|
|
|
|
sway_cmd bar_cmd_modifier;
|
|
|
|
sway_cmd bar_cmd_output;
|
|
|
|
sway_cmd bar_cmd_height;
|
|
|
|
sway_cmd bar_cmd_hidden_state;
|
|
|
|
sway_cmd bar_cmd_icon_theme;
|
|
|
|
sway_cmd bar_cmd_id;
|
|
|
|
sway_cmd bar_cmd_position;
|
|
|
|
sway_cmd bar_cmd_separator_symbol;
|
|
|
|
sway_cmd bar_cmd_status_command;
|
2019-01-11 16:12:24 +11:00
|
|
|
sway_cmd bar_cmd_status_edge_padding;
|
2019-01-11 15:43:45 +11:00
|
|
|
sway_cmd bar_cmd_status_padding;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd bar_cmd_pango_markup;
|
|
|
|
sway_cmd bar_cmd_strip_workspace_numbers;
|
2018-11-18 03:11:28 +11:00
|
|
|
sway_cmd bar_cmd_strip_workspace_name;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd bar_cmd_swaybar_command;
|
2019-01-16 13:25:28 +11:00
|
|
|
sway_cmd bar_cmd_tray_bindcode;
|
2018-12-10 02:10:41 +11:00
|
|
|
sway_cmd bar_cmd_tray_bindsym;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd bar_cmd_tray_output;
|
|
|
|
sway_cmd bar_cmd_tray_padding;
|
2019-04-13 02:30:36 +10:00
|
|
|
sway_cmd bar_cmd_unbindcode;
|
|
|
|
sway_cmd bar_cmd_unbindsym;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd bar_cmd_wrap_scroll;
|
|
|
|
sway_cmd bar_cmd_workspace_buttons;
|
2020-10-03 23:45:26 +10:00
|
|
|
sway_cmd bar_cmd_workspace_min_width;
|
2017-11-23 13:20:41 +11:00
|
|
|
|
|
|
|
sway_cmd bar_colors_cmd_active_workspace;
|
|
|
|
sway_cmd bar_colors_cmd_background;
|
|
|
|
sway_cmd bar_colors_cmd_focused_background;
|
|
|
|
sway_cmd bar_colors_cmd_binding_mode;
|
|
|
|
sway_cmd bar_colors_cmd_focused_workspace;
|
|
|
|
sway_cmd bar_colors_cmd_inactive_workspace;
|
|
|
|
sway_cmd bar_colors_cmd_separator;
|
|
|
|
sway_cmd bar_colors_cmd_focused_separator;
|
|
|
|
sway_cmd bar_colors_cmd_statusline;
|
|
|
|
sway_cmd bar_colors_cmd_focused_statusline;
|
|
|
|
sway_cmd bar_colors_cmd_urgent_workspace;
|
|
|
|
|
2017-12-13 02:55:20 +11:00
|
|
|
sway_cmd input_cmd_seat;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd input_cmd_accel_profile;
|
2019-06-17 19:38:41 +10:00
|
|
|
sway_cmd input_cmd_calibration_matrix;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd input_cmd_click_method;
|
2018-09-29 19:49:41 +10:00
|
|
|
sway_cmd input_cmd_drag;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd input_cmd_drag_lock;
|
|
|
|
sway_cmd input_cmd_dwt;
|
|
|
|
sway_cmd input_cmd_events;
|
|
|
|
sway_cmd input_cmd_left_handed;
|
2018-04-25 04:39:29 +10:00
|
|
|
sway_cmd input_cmd_map_from_region;
|
2018-04-09 04:15:13 +10:00
|
|
|
sway_cmd input_cmd_map_to_output;
|
2019-10-29 11:26:00 +11:00
|
|
|
sway_cmd input_cmd_map_to_region;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd input_cmd_middle_emulation;
|
|
|
|
sway_cmd input_cmd_natural_scroll;
|
|
|
|
sway_cmd input_cmd_pointer_accel;
|
2018-11-18 06:31:33 +11:00
|
|
|
sway_cmd input_cmd_scroll_factor;
|
2018-04-18 23:19:23 +10:00
|
|
|
sway_cmd input_cmd_repeat_delay;
|
|
|
|
sway_cmd input_cmd_repeat_rate;
|
2018-07-12 06:03:06 +10:00
|
|
|
sway_cmd input_cmd_scroll_button;
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd input_cmd_scroll_method;
|
|
|
|
sway_cmd input_cmd_tap;
|
2018-07-14 15:01:47 +10:00
|
|
|
sway_cmd input_cmd_tap_button_map;
|
2020-06-20 04:11:57 +10:00
|
|
|
sway_cmd input_cmd_tool_mode;
|
2018-07-23 06:22:16 +10:00
|
|
|
sway_cmd input_cmd_xkb_capslock;
|
2019-07-13 12:04:29 +10:00
|
|
|
sway_cmd input_cmd_xkb_file;
|
2017-12-15 21:22:51 +11:00
|
|
|
sway_cmd input_cmd_xkb_layout;
|
|
|
|
sway_cmd input_cmd_xkb_model;
|
2018-07-23 06:22:16 +10:00
|
|
|
sway_cmd input_cmd_xkb_numlock;
|
2017-12-15 21:22:51 +11:00
|
|
|
sway_cmd input_cmd_xkb_options;
|
|
|
|
sway_cmd input_cmd_xkb_rules;
|
2019-06-10 04:17:28 +10:00
|
|
|
sway_cmd input_cmd_xkb_switch_layout;
|
2017-12-15 21:22:51 +11:00
|
|
|
sway_cmd input_cmd_xkb_variant;
|
2017-11-23 13:20:41 +11:00
|
|
|
|
2020-03-03 01:30:50 +11:00
|
|
|
sway_cmd output_cmd_adaptive_sync;
|
2018-06-03 11:33:16 +10:00
|
|
|
sway_cmd output_cmd_background;
|
|
|
|
sway_cmd output_cmd_disable;
|
|
|
|
sway_cmd output_cmd_dpms;
|
|
|
|
sway_cmd output_cmd_enable;
|
2019-09-25 20:58:27 +10:00
|
|
|
sway_cmd output_cmd_max_render_time;
|
2018-06-03 11:33:16 +10:00
|
|
|
sway_cmd output_cmd_mode;
|
2021-07-18 20:05:47 +10:00
|
|
|
sway_cmd output_cmd_modeline;
|
2018-06-03 11:33:16 +10:00
|
|
|
sway_cmd output_cmd_position;
|
2021-09-03 11:45:23 +10:00
|
|
|
sway_cmd output_cmd_render_bit_depth;
|
2018-06-03 11:33:16 +10:00
|
|
|
sway_cmd output_cmd_scale;
|
2019-11-14 05:23:36 +11:00
|
|
|
sway_cmd output_cmd_scale_filter;
|
2019-02-11 11:56:57 +11:00
|
|
|
sway_cmd output_cmd_subpixel;
|
2019-05-11 16:57:53 +10:00
|
|
|
sway_cmd output_cmd_toggle;
|
2018-06-03 11:33:16 +10:00
|
|
|
sway_cmd output_cmd_transform;
|
|
|
|
|
2017-12-15 03:11:56 +11:00
|
|
|
sway_cmd seat_cmd_attach;
|
2018-04-11 01:32:37 +10:00
|
|
|
sway_cmd seat_cmd_cursor;
|
2018-12-27 16:32:15 +11:00
|
|
|
sway_cmd seat_cmd_fallback;
|
|
|
|
sway_cmd seat_cmd_hide_cursor;
|
2019-12-12 03:00:39 +11:00
|
|
|
sway_cmd seat_cmd_idle_inhibit;
|
|
|
|
sway_cmd seat_cmd_idle_wake;
|
2019-11-04 06:20:05 +11:00
|
|
|
sway_cmd seat_cmd_keyboard_grouping;
|
2019-02-01 14:58:52 +11:00
|
|
|
sway_cmd seat_cmd_pointer_constraint;
|
2020-02-16 10:40:18 +11:00
|
|
|
sway_cmd seat_cmd_shortcuts_inhibitor;
|
2019-06-02 05:05:09 +10:00
|
|
|
sway_cmd seat_cmd_xcursor_theme;
|
2017-12-15 03:11:56 +11:00
|
|
|
|
2017-11-23 13:20:41 +11:00
|
|
|
sway_cmd cmd_ipc_cmd;
|
|
|
|
sway_cmd cmd_ipc_events;
|
|
|
|
sway_cmd cmd_ipc_event_cmd;
|
|
|
|
|
|
|
|
#endif
|