From 4f9af09f230766fe45686dc7b8b4e10427840434 Mon Sep 17 00:00:00 2001 From: wdbw Date: Sat, 4 Jun 2016 17:20:27 +0200 Subject: [PATCH 1/6] Add missing layout modes in sway(5) --- sway/sway.5.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/sway.5.txt b/sway/sway.5.txt index 8faa5345f..021b37361 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt @@ -100,7 +100,7 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( **layout** :: Sets the layout mode of the focused container. _mode_ can be one of _splith_, - _splitv_, or _toggle split_. + _splitv_, _toggle split_, _stacking_ or _tabbed_. **move** :: Moves the focused container _left_, _right_, _up_, or _down_. From 374654246221f01150f24c37063b6149b769928b Mon Sep 17 00:00:00 2001 From: Zandr Martin Date: Sat, 4 Jun 2016 10:43:23 -0500 Subject: [PATCH 2/6] add documentation for client commands --- sway/commands.c | 6 +++--- sway/sway-bar.5.txt | 2 +- sway/sway.5.txt | 48 +++++++++++++++++++++++++++++++++++++++++++++ swaylock/main.c | 2 +- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/sway/commands.c b/sway/commands.c index 3befee133..83a9e7e97 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -427,7 +427,7 @@ static struct cmd_results *cmd_border(int argc, char **argv) { static struct cmd_results *parse_border_color(struct border_colors *border_colors, const char *cmd_name, int argc, char **argv) { struct cmd_results *error = NULL; if (argc != 5) { - return cmd_results_new(CMD_INVALID, cmd_name, "Requires exact 5 color values"); + return cmd_results_new(CMD_INVALID, cmd_name, "Requires exactly five color values"); } uint32_t colors[5]; @@ -476,7 +476,7 @@ static struct cmd_results *cmd_client_background(int argc, char **argv) { uint32_t background; if (argc != 1) { - return cmd_results_new(CMD_INVALID, "client.background", "Expect exact 1 value"); + return cmd_results_new(CMD_INVALID, "client.background", "Requires exactly one color value"); } error = add_color("client.background", buffer, argv[0]); @@ -737,7 +737,7 @@ static struct cmd_results *cmd_floating_minimum_size(int argc, char **argv) { } - sway_log(L_DEBUG, "New floating_minimum_size: '%d' x '%d'", config->floating_minimum_width, + sway_log(L_DEBUG, "New floating_minimum_size: '%d' x '%d'", config->floating_minimum_width, config->floating_minimum_height); return cmd_results_new(CMD_SUCCESS, NULL, NULL); diff --git a/sway/sway-bar.5.txt b/sway/sway-bar.5.txt index 322dc32ba..d07274408 100644 --- a/sway/sway-bar.5.txt +++ b/sway/sway-bar.5.txt @@ -61,7 +61,7 @@ Colors ------ Colors are defined within a _colors { }_ block inside a _bar { }_ block. Colors -must be defined in hex. E.g. _#fff000_ or _#fff000ff_ when including the alpha +must be defined in hex. i.e. _#rrggbb_ or _#rrggbbaa_ when including the alpha channel. **background** :: diff --git a/sway/sway.5.txt b/sway/sway.5.txt index 8faa5345f..c67d8bec9 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt @@ -150,6 +150,54 @@ or triggered at runtime. **bindcode** is also available for binding with key codes instead of key names. +**client**. :: + The client commands control the colors of the view borders and title bars. All + of the client commands _require_ five color values. (The one exception is + **client.background** which _requires_ one color value.) If you only want to + specify a subset, supply default colors for all the others. Colors must be + defined in hex. i.e. _#rrggbb_ or _#rrggbbaa_ when including the alpha + channel. + + + The command tokens are: + **color_class**::: Specifies the view to which the colors apply. + **client.background**:::: The color a view will be painted, underneath the + client itself. This will only be visible if a client does not fully + cover its allocated view space. This command only requires one color. _Note_: + This is not currently implemented. + **client.focused**:::: The view that has focus. + **client.focused_inactive**:::: A view that has focus within its + container, but the container is not focused. + **client.placeholder**:::: Used when drawing placeholder view contents. + Only background and text colors are used. _Note_: This is not + currently implemented. + **client.unfocused**:::: A view that does not have focus. + **client.urgent**:::: A view with an urgency hint. _Note_: This is not + currently implemented. + **border**::: The border around the title bar. + **background**::: The background of the title bar. + **text**::: The text color of the title bar. + **indicator**::: The color used to indicate where a new view will open. In a + tiled container, this would paint the right border of the current view if + a new view would be opened to the right. _Note_: This is not currently + implemented. + **child_border**::: The border around the view itself. + ++ +The default colors are: ++ +-- +[options="header"] +|=========================================================================== +|color_class |border |background |text |indicator |child_border +|background |n/a |#ffffffff |n/a |n/a |n/a +|focused |#4c7899ff |#285577ff |#ffffffff |#2e9ef4ff |#285577ff +|focused_inactive |#333333ff |#5f676aff |#ffffffff |#484e50ff |#5f676aff +|unfocused |#333333ff |#222222ff |#888888ff |#292d2eff |#222222ff +|urgent |#2f343aff |#900000ff |#ffffffff |#900000ff |#900000ff +|placeholder |#000000ff |#0c0c0cff |#ffffffff |#000000ff |#0c0c0cff +|=========================================================================== +-- + **debuglog** :: Enables, disables or toggles logging for debug. The toggle argument cannot be used in the configuration file. diff --git a/swaylock/main.c b/swaylock/main.c index 2c69f7fdd..cc543056d 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -360,7 +360,7 @@ int main(int argc, char **argv) { { int colorlen = strlen(optarg); if (colorlen < 6 || colorlen == 7 || colorlen > 8) { - sway_log(L_ERROR, "color must be specified in 3 or 4 byte format, e.g. ff0000 or ff0000ff"); + sway_log(L_ERROR, "color must be specified in 3 or 4 byte format, e.g. rrggbb or rrggbbaa"); exit(EXIT_FAILURE); } render_data.color = strtol(optarg, NULL, 16); From 6e7659ba1396ce8277e94d2b99ec774709fbac75 Mon Sep 17 00:00:00 2001 From: Zandr Martin Date: Sat, 4 Jun 2016 13:35:41 -0500 Subject: [PATCH 3/6] make numpad enter key work in swaylock see issue #647 --- swaylock/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/swaylock/main.c b/swaylock/main.c index cc543056d..b5ce63ef4 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -119,6 +119,7 @@ void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t cod if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { switch (sym) { + case XKB_KEY_KP_Enter: // fallthrough case XKB_KEY_Return: render_data.auth_state = AUTH_STATE_VALIDATING; @@ -159,7 +160,7 @@ void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t cod case XKB_KEY_Super_L: // fallthrough case XKB_KEY_Super_R: // fallthrough case XKB_KEY_Hyper_L: // fallthrough - case XKB_KEY_Hyper_R: // fallthrough + case XKB_KEY_Hyper_R: { // don't draw screen on modifier keys break; @@ -360,7 +361,7 @@ int main(int argc, char **argv) { { int colorlen = strlen(optarg); if (colorlen < 6 || colorlen == 7 || colorlen > 8) { - sway_log(L_ERROR, "color must be specified in 3 or 4 byte format, e.g. rrggbb or rrggbbaa"); + sway_log(L_ERROR, "color must be specified in 3 or 4 byte format, i.e. rrggbb or rrggbbaa"); exit(EXIT_FAILURE); } render_data.color = strtol(optarg, NULL, 16); From d4eb964fd1017ecc7dacfe6925ee18faa5c1dbcd Mon Sep 17 00:00:00 2001 From: Zandr Martin Date: Sun, 5 Jun 2016 09:03:13 -0500 Subject: [PATCH 4/6] document `assign` command --- sway/sway.5.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sway/sway.5.txt b/sway/sway.5.txt index ffa181f77..bd2de12d4 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt @@ -140,6 +140,12 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( The following commands may be used either in the configuration file or triggered at runtime. +**assign** [→] :: + Assigns views matching _criteria_ (see **Criteria** section below) to + _workspace_. The → (U+2192) is optional and purely for aesthetics. This + command is exactly equivalent to "for_window move container to + workspace ". + **bindsym** :: Binds _key combo_ to execute _command_ when pressed. You may use XKB key names here (**xev**(1) is a good tool for discovering them). An example From e8c0ef98b1c1068783350c76b44c4e40b7534137 Mon Sep 17 00:00:00 2001 From: Roosembert Palacios Date: Sun, 5 Jun 2016 23:36:27 +0200 Subject: [PATCH 5/6] Sway: Configuration: Support for escaping line breaks. Escape line return in configuration file with the '\' character. Similar to shell scripts. Signed-off-by: Roosembert Palacios --- sway/config.c | 42 +++++++++++++++++++++++++++++++++++++++++- sway/sway.5.txt | 6 ++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/sway/config.c b/sway/config.c index 151081235..c1eec22ff 100644 --- a/sway/config.c +++ b/sway/config.c @@ -455,10 +455,11 @@ bool load_include_configs(const char *path, struct sway_config *config) { bool read_config(FILE *file, struct sway_config *config) { bool success = true; + bool multiline = false; enum cmd_status block = CMD_BLOCK_END; int line_number = 0; - char *line; + char *line, *mlinebuf = NULL; while (!feof(file)) { line = read_line(file); line_number++; @@ -467,6 +468,45 @@ bool read_config(FILE *file, struct sway_config *config) { free(line); continue; } + size_t length = strlen(line); + if (line[length-1] == '\\') { + // Start of multiline + if (feof(file)){ + sway_log(L_ERROR, "Error on line %i '%s': Unexpected EOF on "\ + "multiline command", line_number, line); + free(line); + continue; + } + line[length-1] = '\0'; + multiline = true; + } else + multiline = false; + + if (multiline || mlinebuf){ + size_t mlinebuf_length; + if (mlinebuf) + mlinebuf_length = strlen(mlinebuf); + else + mlinebuf_length = 0; + + char *tmp = malloc(mlinebuf_length+length+1); // + '\0' + tmp[0]='\0'; // if mlinebuf_length==0 strncpy won't do anything. Make a null string. + strncpy(tmp, mlinebuf, mlinebuf_length); + tmp[mlinebuf_length]='\0'; // strncpy won't add '\0' at the end... + strcat(tmp, line); + if (mlinebuf) + free(mlinebuf); + free(line); + mlinebuf = tmp; + if (multiline) // The following line is part of a multi line config. + continue; + else { // This is the last line of a multi line config. + line = mlinebuf; + sway_log(L_INFO, "Processing parsed multiline command '%s'", line); + mlinebuf = NULL; + } + } + struct cmd_results *res = config_command(line, block); switch(res->status) { case CMD_FAILURE: diff --git a/sway/sway.5.txt b/sway/sway.5.txt index bd2de12d4..397b6d873 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt @@ -16,6 +16,12 @@ on startup. These commands usually consist of setting your preferences and setting key bindings. An example config is likely present in /etc/sway/config for you to check out. +Lines in the configuration file might be extended through multiple lines by +adding a '\' character at the end of line. e.g.: + + bindsym Shift+XF86AudioRaiseVolume exec pactl set-sink-volume \ + $(pactl list sinks | grep -B 1 RUNNING | sed '1q;d' | sed 's/[^0-9]\+//g') +5% + These commands can be executed in your config file, via **sway-msg**(1), or via the bindsym command. From 230591fa4e4911ffbb38da2ee79650e62d98415f Mon Sep 17 00:00:00 2001 From: Roosembert Palacios Date: Mon, 6 Jun 2016 00:17:27 +0200 Subject: [PATCH 6/6] Common: Readline: Ignore newline on '\' escaped line ends. Escape line return when reading from a file with the '\' character. Similar to shell scripts. Signed-off-by: Roosembert Palacios --- common/readline.c | 7 +++++++ sway/config.c | 42 +----------------------------------------- 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/common/readline.c b/common/readline.c index 76ed69268..5106172c3 100644 --- a/common/readline.c +++ b/common/readline.c @@ -5,17 +5,24 @@ char *read_line(FILE *file) { size_t length = 0, size = 128; char *string = malloc(size); + char lastChar = '\0'; if (!string) { return NULL; } while (1) { int c = getc(file); + if (c == '\n' && lastChar == '\\'){ + --length; // Ignore last character. + lastChar = '\0'; + continue; + } if (c == EOF || c == '\n' || c == '\0') { break; } if (c == '\r') { continue; } + lastChar = c; if (length == size) { char *new_string = realloc(string, size *= 2); if (!new_string) { diff --git a/sway/config.c b/sway/config.c index c1eec22ff..151081235 100644 --- a/sway/config.c +++ b/sway/config.c @@ -455,11 +455,10 @@ bool load_include_configs(const char *path, struct sway_config *config) { bool read_config(FILE *file, struct sway_config *config) { bool success = true; - bool multiline = false; enum cmd_status block = CMD_BLOCK_END; int line_number = 0; - char *line, *mlinebuf = NULL; + char *line; while (!feof(file)) { line = read_line(file); line_number++; @@ -468,45 +467,6 @@ bool read_config(FILE *file, struct sway_config *config) { free(line); continue; } - size_t length = strlen(line); - if (line[length-1] == '\\') { - // Start of multiline - if (feof(file)){ - sway_log(L_ERROR, "Error on line %i '%s': Unexpected EOF on "\ - "multiline command", line_number, line); - free(line); - continue; - } - line[length-1] = '\0'; - multiline = true; - } else - multiline = false; - - if (multiline || mlinebuf){ - size_t mlinebuf_length; - if (mlinebuf) - mlinebuf_length = strlen(mlinebuf); - else - mlinebuf_length = 0; - - char *tmp = malloc(mlinebuf_length+length+1); // + '\0' - tmp[0]='\0'; // if mlinebuf_length==0 strncpy won't do anything. Make a null string. - strncpy(tmp, mlinebuf, mlinebuf_length); - tmp[mlinebuf_length]='\0'; // strncpy won't add '\0' at the end... - strcat(tmp, line); - if (mlinebuf) - free(mlinebuf); - free(line); - mlinebuf = tmp; - if (multiline) // The following line is part of a multi line config. - continue; - else { // This is the last line of a multi line config. - line = mlinebuf; - sway_log(L_INFO, "Processing parsed multiline command '%s'", line); - mlinebuf = NULL; - } - } - struct cmd_results *res = config_command(line, block); switch(res->status) { case CMD_FAILURE: