diff --git a/common/readline.c b/common/readline.c index 76ed6926..5106172c 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/commands.c b/sway/commands.c index 08920c1c..3a6b2af5 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -1639,7 +1639,7 @@ static struct cmd_results *cmd_output(int argc, char **argv) { } char *src = join_args(argv + i, argc - i - 1); char *mode = argv[argc - 1]; - if (wordexp(src, &p, 0) != 0) { + if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { return cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s)", src); } free(src); @@ -1699,9 +1699,13 @@ static struct cmd_results *cmd_output(int argc, char **argv) { swayc_t *cont = NULL; for (int i = 0; i < root_container.children->length; ++i) { cont = root_container.children->items[i]; - if (cont->name && strcmp(cont->name, output->name) == 0) { + if (cont->name && ((strcmp(cont->name, output->name) == 0) || (strcmp(output->name, "*") == 0))) { apply_output_config(output, cont); - break; + + if (strcmp(output->name, "*") != 0) { + // stop looking if the output config isn't applicable to all outputs + break; + } } } } @@ -2153,12 +2157,26 @@ static int compare_set_qsort(const void *_l, const void *_r) { } static struct cmd_results *cmd_set(int argc, char **argv) { + char *tmp; + int size; struct cmd_results *error = NULL; if (!config->reading) return cmd_results_new(CMD_FAILURE, "set", "Can only be used in config file."); if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { return error; } + if (argv[0][0] != '$') { + sway_log(L_INFO, "Warning: variable '%s' doesn't start with $", argv[0]); + + size = asprintf(&tmp, "%s%s", "$", argv[0]); + if (size == -1) { + return cmd_results_new(CMD_FAILURE, "set", "Not possible to create variable $'%s'", argv[0]); + } + + argv[0] = strdup(tmp); + free(tmp); + } + struct sway_variable *var = NULL; // Find old variable if it exists int i; @@ -3040,7 +3058,7 @@ static struct cmd_results *bar_cmd_swaybar_command(int argc, char **argv) { } static struct cmd_results *bar_cmd_tray_output(int argc, char **argv) { - sway_log(L_ERROR, "warning: tray_output is not supported on wayland"); + sway_log(L_ERROR, "Warning: tray_output is not supported on wayland"); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/config.c b/sway/config.c index 321534ed..07b1f2f7 100644 --- a/sway/config.c +++ b/sway/config.c @@ -403,6 +403,11 @@ static bool load_include_config(const char *path, const char *parent_dir, struct char *real_path = realpath(full_path, NULL); free(full_path); + if (real_path == NULL) { + sway_log(L_DEBUG, "%s not found.", path); + return false; + } + // check if config has already been included int j; for (j = 0; j < config->config_chain->length; ++j) { diff --git a/sway/sway-bar.5.txt b/sway/sway-bar.5.txt index d0727440..dc4a673c 100644 --- a/sway/sway-bar.5.txt +++ b/sway/sway-bar.5.txt @@ -19,10 +19,15 @@ Commands -------- **status_command** :: - Executes the bar _status command_ with _sh -c_. + Executes the bar _status command_ with _sh -c_. Each line of text printed to + stdout from this command will be displayed in the status area of the bar. You + can also use the i3bar JSON protocol: + + + https://i3wm.org/docs/i3bar-protocol.html **pango_markup** :: - Enables or disables pango markup for plaintext statuslines. + Enables or disables pango markup for status lines. This has no effect on + status lines using the i3bar JSON protocol. **id** :: Sets the ID of the bar. @@ -112,4 +117,4 @@ channel. See Also -------- -**sway**(5) **sway-input**(5) +**sway**(5) diff --git a/sway/sway-input.5.txt b/sway/sway-input.5.txt index c2637830..2ac878cd 100644 --- a/sway/sway-input.5.txt +++ b/sway/sway-input.5.txt @@ -37,7 +37,8 @@ Commands Enables or disables middle click emulation. **input** natural_scroll :: - Enables or disables natural scrolling for the specified input device. + Enables or disables natural (inverted) scrolling for the specified input + device. **input** pointer_accel <[-1,1]>:: Changes the pointer acceleration for the specified input device. @@ -51,4 +52,4 @@ Commands See Also -------- -**sway**(5) **sway-bar**(5) +**sway**(5) diff --git a/sway/sway.1.txt b/sway/sway.1.txt index 1243c354..f62e27f4 100644 --- a/sway/sway.1.txt +++ b/sway/sway.1.txt @@ -52,7 +52,7 @@ You may run sway from an ongoing x11 session to run it within x. Otherwise, you can run sway on a tty and it will use your outputs directly. *Important note for nvidia users*: The proprietary nvidia driver does _not_ have -support for Wayland as of 2016-03-27. Use nouveau. +support for Wayland as of 2016-06-10. Use nouveau. Commands -------- @@ -60,7 +60,7 @@ Commands If sway is currently running, you may run _sway [command]_ to send _command_ to the running instance of sway. The same commands you would use in the config file are valid here (see **sway**(5)). For compatibility reasons, you may also issue -commands with **sway-msg**(1) or **i3-msg**(1) (or even with **i3**(1), probably). +commands with **swaymsg**(1) or **i3-msg**(1) (or even with **i3**(1), probably). Configuration ------------- @@ -69,11 +69,14 @@ If _-c_ is not specified, sway will look in several locations for your config file. The suggested location for your config file is ~/.config/sway/config. ~/.sway/config will also work, and the rest of the usual XDG config locations are supported. If no sway config is found, sway will attempt to load an i3 -config from all the config locations i3 supports. At last, sway looks for a -config file in a fallback directory, which is /etc/sway/ by default. A standard +config from all the config locations i3 supports. Sway looks for a config file in +a fallback directory as a last resort, which is /etc/sway/ by default. A standard configuration file is installed at this location. If still nothing is found, you will receive an error. +To write your own config, it's suggested that you copy the default config file to +the location of your choosing and start there. + For information on the config file format, see **sway**(5). Authors @@ -86,4 +89,4 @@ source contributors. For more information about sway development, see See Also -------- -**sway**(5) **swaymsg**(1) **swaygrab**(1) **sway-input** (5) **sway-bar** (5) +**sway**(5) **swaymsg**(1) **swaygrab**(1) **sway-input**(5) **sway-bar**(5) diff --git a/sway/sway.5.txt b/sway/sway.5.txt index bd2de12d..00806112 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt @@ -16,7 +16,13 @@ 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. -These commands can be executed in your config file, via **sway-msg**(1), or via +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 **swaymsg**(1), or via the bindsym command. Commands @@ -30,53 +36,28 @@ The following commands may only be used in the configuration file. + See **sway-bar**(5) for details. -**input** :: - Append _{_ to this command, the following lines will be commands to configure - the named input device, and _}_ on its own line will close the block. - + - See **sway-input**(5) for details. - **set** :: - Creates a substitution for _value_ that can be used with $_name_ in other - commands. + Sets variable $name to _value_. You can use the new variable in the arguments + of future commands. The following commands cannot be used directly in the configuration file. They are expected to be used with **bindsym** or at runtime through **swaymsg**(1). **border** []:: Set border style for focused window. _normal_ includes a border of thickness - _n_ and a title bar. _pixel_ is just the border without title bar. Default is - _normal_ with border thickness 2. + _n_ and a title bar. _pixel_ is a border without title bar _n_ pixels thick. + Default is _normal_ with border thickness 2. **border** :: Set border style for focused window to _none_ or _toggle_ between the available border styles: _normal_, _pixel_, _none_. -**new_window** []:: - Set default border style for new windows. - -**new_float** []:: - Set default border style for new floating windows. This does only apply to - windows that are spawned in floating mode. - **exit**:: Exit sway and end your Wayland session. **floating** :: Make focused view floating, non-floating, or the opposite of what it is now. -**floating_maximum_size** x :: - Specifies the maximum dimensions of floating windows. - Uses the container dimensions as default. - -1 x -1 will remove any restriction on dimentions. - 0 x 0 has the same behavior as not setting any value. - If in conflict this option has precedence over floating_minimum_size. - -**floating_minimum_size** x :: - Specifies the minimum dimensions of floating windows. - Default parameters are 75 x 50. - -1 and 0 are invalid parameters, default will be used instead. - **focus** :: Direction may be one of _up_, _down_, _left_, _right_, or _parent_. The directional focus commands will move the focus in that direction. The parent @@ -95,9 +76,6 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( **fullscreen**:: Toggles fullscreen status for the focused view. -**hide_edge_borders** :: - Hide window borders adjacent to the screen edges. Default is _none_. - **layout** :: Sets the layout mode of the focused container. _mode_ can be one of _splith_, _splitv_, _toggle split_, _stacking_ or _tabbed_. @@ -134,8 +112,8 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( Equivalent to **split toggle**. **sticky** :: - If enabled and the windows is floating it will always be present on the active - workspace on that output. + "Sticks" a floating window to the current output so that it shows up on all + workspaces. The following commands may be used either in the configuration file or triggered at runtime. @@ -149,7 +127,7 @@ or triggered at runtime. **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 - bindsym command would be _bindsym Mod1+Shift+f exec firefox_, which would + bindsym command would be **bindsym Mod1+Shift+f exec firefox**, which would execute Firefox if the alt, shift, and F keys are pressed together. Any valid sway command is eligible to be bound to a key combo. + @@ -195,18 +173,18 @@ 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 +|background |n/a |#ffffff |n/a |n/a |n/a +|focused |#4c7899 |#285577 |#ffffff |#2e9ef4 |#285577 +|focused_inactive |#333333 |#5f676a |#ffffff |#484e50 |#5f676a +|unfocused |#333333 |#222222 |#888888 |#292d2e |#222222 +|urgent |#2f343a |#900000 |#ffffff |#900000 |#900000 +|placeholder |#000000 |#0c0c0c |#ffffff |#000000 |#0c0c0c |=========================================================================== -- **debuglog** :: - Enables, disables or toggles logging for debug. The toggle argument cannot - be used in the configuration file. + Enables, disables or toggles debug logging. The toggle argument cannot be used + in the configuration file. **exec** :: Executes _shell command_ with sh. @@ -215,21 +193,32 @@ The default colors are: Like exec, but the shell command will be executed _again_ after *reload* or *restart* is executed. +**floating_maximum_size** x :: + Specifies the maximum dimensions of floating windows. + Uses the container dimensions as default. + -1 x -1 will remove any restriction on dimentions. + 0 x 0 has the same behavior as not setting any value. + If in conflict this option has precedence over floating_minimum_size. + +**floating_minimum_size** x :: + Specifies the minimum dimensions of floating windows. + Default parameters are 75 x 50. + -1 and 0 are invalid parameters, default will be used instead. + **floating_modifier** [normal|inverse]:: - When the _modifier_ key is held down, you may use left click to drag floating + When the _modifier_ key is held down, you may hold left click to move floating windows, and right click to resize them. Unlike i3, this modifier may also be used to resize and move windows that are tiled. With the _inverse_ mode enabled, left click is used for resizing and right click for dragging. The mode paramenter is optional and defaults to _normal_ if it isn't defined. **floating_scroll** [command]:: - Sets the command to be executed on scrolling in the specified - direction while holding the floating modifier. Resets the - command, when given no arguments. + Sets a command to be executed when the mouse wheel is scrolled in the + specified direction while holding the floating modifier. Resets the command, + when given no arguments. **focus_follows_mouse** :: - If set to _yes_, the currently focused view will change as you move your - mouse around the screen to the view that ends up underneath your mouse. + If set to _yes_, moving your mouse over a window will focus that window. **for_window** :: Whenever a window that matches _criteria_ appears, run list of commands. See @@ -256,6 +245,15 @@ The default colors are: workspace (or current workspace), and _current_ changes gaps for the current view or workspace. +**hide_edge_borders** :: + Hide window borders adjacent to the screen edges. Default is _none_. + +**input** :: + Append _{_ to this command, the following lines will be commands to configure + the named input device, and _}_ on its own line will close the block. + + + See **sway-input**(5) for details. + **smart_gaps** :: If smart_gaps are _on_ then gaps will only be enabled if a workspace has more than one child container. @@ -269,8 +267,20 @@ The default colors are: When _output_: place mouse at center of newly focused window when changing output. When _none_: don't move mouse. +**new_window** []:: + Set default border style for new windows. + +**new_float** []:: + Set default border style for new floating windows. This only applies to + windows that are spawned in floating mode, not windows that become floating + after the fact. + **output** :: Configures the specified output to use the given resolution. + + + _Note_: sway does not currently support modesetting. Your output's native + resolution will be used and the screen will be scaled from the resolution + specified to your native resolution. **output** :: Configures the specified output to be arranged at the given position.