summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt26
-rw-r--r--README.md1
-rw-r--r--config11
-rw-r--r--include/stringop.h4
-rw-r--r--sway.1.txt84
-rw-r--r--sway.5.txt90
-rw-r--r--sway/commands.c6
-rw-r--r--sway/config.c9
-rw-r--r--sway/readline.c13
-rw-r--r--sway/stringop.c52
10 files changed, 249 insertions, 47 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 27839b1d..b4bdf756 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,3 +43,29 @@ INSTALL(
43 FILES ${PROJECT_SOURCE_DIR}/config 43 FILES ${PROJECT_SOURCE_DIR}/config
44 DESTINATION /etc/sway/ 44 DESTINATION /etc/sway/
45) 45)
46
47ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.1
48 COMMAND a2x --no-xmllint --doctype manpage --format manpage
49 -D ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}/sway.1.txt
50 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sway.1.txt
51)
52
53ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.5
54 COMMAND a2x --no-xmllint --doctype manpage --format manpage
55 -D ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}/sway.5.txt
56 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sway.5.txt
57)
58
59ADD_CUSTOM_TARGET(man ALL
60 DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.1
61 DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.5)
62
63INSTALL(
64 FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.1
65 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
66)
67
68INSTALL(
69 FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.5
70 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man5
71)
diff --git a/README.md b/README.md
index 43a63c25..8c312984 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@ Dependencies:
31* cmake 31* cmake
32* [wlc](https://github.com/Cloudef/wlc) 32* [wlc](https://github.com/Cloudef/wlc)
33* xwayland 33* xwayland
34* asciidoc
34 35
35Compiling: 36Compiling:
36 37
diff --git a/config b/config
index 154f33ca..1e94973c 100644
--- a/config
+++ b/config
@@ -9,10 +9,13 @@
9 9
10 10
11### Variables 11### Variables
12 12#
13set $mod Mod4 # Logo key. Use Mod1 for Alt. 13# Logo key. Use Mod1 for Alt.
14set $term urxvt # Your preferred terminal emulator 14set $mod Mod4
15set $menu dmenu_run # Your preferred application launcher 15# Your preferred terminal emulator
16set $term urxvt
17# Your preferred application launcher
18set $menu dmenu_run
16 19
17### Key bindings 20### Key bindings
18# 21#
diff --git a/include/stringop.h b/include/stringop.h
index a5346829..03387345 100644
--- a/include/stringop.h
+++ b/include/stringop.h
@@ -2,8 +2,8 @@
2#define _SWAY_STRINGOP_H 2#define _SWAY_STRINGOP_H
3#include "list.h" 3#include "list.h"
4 4
5char *strip_whitespace(char *str, int *trimmed_start); 5void strip_whitespace(char *str);
6char *strip_comments(char *str); 6void strip_comments(char *str);
7list_t *split_string(const char *str, const char *delims); 7list_t *split_string(const char *str, const char *delims);
8void free_flat_list(list_t *list); 8void free_flat_list(list_t *list);
9char *code_strchr(const char *string, char delimiter); 9char *code_strchr(const char *string, char delimiter);
diff --git a/sway.1.txt b/sway.1.txt
new file mode 100644
index 00000000..36586e1d
--- /dev/null
+++ b/sway.1.txt
@@ -0,0 +1,84 @@
1/////
2vim:set ts=4 sw=4 tw=82 noet:
3/////
4:quotes.~:
5
6sway (1)
7========
8
9Name
10----
11sway - SirCmpwn's Wayland window manager
12
13Synopsis
14--------
15'sway' [options] [command]
16
17Options
18-------
19
20*-c, \--config* <config>::
21 Specifies a config file.
22
23*-C, \--validate*::
24 Check the validity of the config file, then exit.
25
26*-d, --debug*::
27 Enables full logging, including debug information.
28
29*-v, \--version*::
30 Show the version number and quit.
31
32*-V, --verbose*::
33 Enables more verbose logging.
34
35*--get-socketpath*::
36 Gets the IPC socket path and prints it, then exits.
37
38Description
39-----------
40
41sway was created to fill the need of an i3-like window manager for Wayland. The
42upstream i3 developers have no intention of porting i3 to Wayland, and projects
43proposed by others ended up as vaporware. Many thanks to the i3 folks for
44providing such a great piece of software, so good that your users would rather
45write an entirely new window manager from scratch that behaved _exactly_ like i3
46rather than switch to something else.
47
48You may run sway from an ongoing x11 session to run it within x. Otherwise, you
49can run sway on a tty and it will use your outputs directly.
50
51*Important note for nvidia users*: The proprietary nvidia driver does _not_ have
52support for Wayland as of 2015-08-17. Use nouveau.
53
54Commands
55--------
56
57If sway is currently running, you may run _sway [command]_ to send _command_ to
58the running instance of sway. The same commands you would use in the config file
59are valid here (see **sway**(5)). For compatability reasons, you may also issue
60commands with **sway-msg**(1) or **i3-msg**(1) (or even with **i3**(1), probably).
61
62Configuration
63-------------
64
65If _-c_ is not specified, sway will look in several locations for your config
66file. The default one is provided at /etc/sway/config. The suggested location for
67your config file is ~/.config/sway/config. ~/.sway/config will also work, and the
68rest of the usual XDG config locations are supported. If no sway config is found,
69sway will attempt to load an i3 config from all the config locations i3 supports.
70If still nothing is found, you will receive an error.
71
72For information on the config file format, see **sway**(5).
73
74Authors
75-------
76
77Maintained by Drew DeVault <sir@cmpwn.com>, who is assisted by other open
78source contributors. For more information about sway development, see
79<https://github.com/SirCmpwn/sway>.
80
81See Also
82--------
83
84**sway**(5)
diff --git a/sway.5.txt b/sway.5.txt
new file mode 100644
index 00000000..9f92dfe8
--- /dev/null
+++ b/sway.5.txt
@@ -0,0 +1,90 @@
1/////
2vim:set ts=4 sw=4 tw=82 noet:
3/////
4sway (5)
5========
6
7Name
8----
9sway - configuration file and commands
10
11Description
12-----------
13
14A sway configuration file is a list of sway commands that are exected by sway on
15startup. These commands usually consist of setting your preferences and setting
16key bindings. An example config is likely present in /etc/sway/config for you to
17check out.
18
19All of these commands may be issued at runtime through **sway-msg**(1).
20
21Commands
22--------
23
24**bindsym** <key combo> <command>::
25 Binds _key combo_ to execute _command_ when pressed. You may use XKB key names
26 here (**xev**(1) is a good tool for discovering them). An example bindsym
27 command would be _bindsym Mod1+Shift+f exec firefox_, which would execute
28 Firefox if the alt, shift, and F keys are pressed together. Any valid sway
29 command is eligible to be bound to a key combo.
30
31**exec** <shell command>::
32 Executes _shell command_ with sh.
33
34**exec_always** <shell command>::
35 Like exec, but the shell command will be executed _again_ after *reload* or
36 *restart* is executed.
37
38**exit**::
39 Exit sway and end your Wayland session.
40
41**floating** toggle::
42 Toggles the "floating" status of the focused view.
43
44**focus** <direction>::
45 Direction may be one of _up_, _down_, _left_, _right_, or _parent_. The
46 directional focus commands will move the focus in that direction. The parent
47 focus command will change the focus to the parent of the currently focused
48 container, which is useful, for example, to open a sibling of the parent
49 container, or to move the entire container around.
50
51**focus_follows_mouse** <yes|no>::
52 If set to _yes_, the currently focused view will change as you move your
53 mouse around the screen to the view that ends up underneath your mouse.
54
55**kill**::
56 Closes the currently focused view.
57
58**layout** <mode>::
59 Sets the layout mode of the focused container. _mode_ can be one of _splith_,
60 _splitv_, or _toggle split_.
61
62**reload**::
63 Reloads the sway config file without restarting sway.
64
65**set** <name> <value>::
66 Creates a substitution for _value_ that can be used with $_name_ in other
67 commands.
68
69**split** <vertical|horizontal>::
70 Splits the current container, vertically or horiziontally. The letters "h" and
71 "v" can be used instead of the full words "vertical" or "horizontal".
72
73**splith**::
74 Equivalent to **split horizontal**.
75
76**splitv**::
77 Equivalent to **split vertical**.
78
79**fullscreen**:
80 Toggles fullscreen status for the focused view.
81
82**workspace** <name>:
83 Switches to the specified workspace.
84
85**workspace** <prev_on_output|next_on_output>:
86 Switches to the next workspace on the current output.
87
88**workspace** <name> output <output>::
89 Specifies that the workspace named _name_ should appear on the specified
90 _output_.
diff --git a/sway/commands.c b/sway/commands.c
index 548cb8ed..7e9169e8 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -504,7 +504,7 @@ static char **split_directive(char *line, int *argc) {
504 if (!*line) return parts; 504 if (!*line) return parts;
505 505
506 int in_string = 0, in_character = 0; 506 int in_string = 0, in_character = 0;
507 int i, j, _; 507 int i, j;
508 for (i = 0, j = 0; line[i]; ++i) { 508 for (i = 0, j = 0; line[i]; ++i) {
509 if (line[i] == '\\') { 509 if (line[i] == '\\') {
510 ++i; 510 ++i;
@@ -517,7 +517,7 @@ static char **split_directive(char *line, int *argc) {
517 char *item = malloc(i - j + 1); 517 char *item = malloc(i - j + 1);
518 strncpy(item, line + j, i - j); 518 strncpy(item, line + j, i - j);
519 item[i - j] = '\0'; 519 item[i - j] = '\0';
520 item = strip_whitespace(item, &_); 520 strip_whitespace(item);
521 if (item[0] == '\0') { 521 if (item[0] == '\0') {
522 free(item); 522 free(item);
523 } else { 523 } else {
@@ -535,7 +535,7 @@ static char **split_directive(char *line, int *argc) {
535 char *item = malloc(i - j + 1); 535 char *item = malloc(i - j + 1);
536 strncpy(item, line + j, i - j); 536 strncpy(item, line + j, i - j);
537 item[i - j] = '\0'; 537 item[i - j] = '\0';
538 item = strip_whitespace(item, &_); 538 strip_whitespace(item);
539 if (*argc == capacity) { 539 if (*argc == capacity) {
540 capacity++; 540 capacity++;
541 parts = realloc(parts, sizeof(char *) * capacity); 541 parts = realloc(parts, sizeof(char *) * capacity);
diff --git a/sway/config.c b/sway/config.c
index 4125f4cd..95d605a3 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -40,7 +40,7 @@ static char* get_config_path() {
40 } else { 40 } else {
41 name = "/sway/config"; 41 name = "/sway/config";
42 temp = malloc(strlen(xdg_config_home) + strlen(name) + 1); 42 temp = malloc(strlen(xdg_config_home) + strlen(name) + 1);
43 strcpy(temp, home); 43 strcpy(xdg_config_home, home);
44 strcat(temp, name); 44 strcat(temp, name);
45 } 45 }
46 if (exists(temp)) { 46 if (exists(temp)) {
@@ -93,7 +93,7 @@ static char* get_config_path() {
93 } else { 93 } else {
94 name = "/i3/config"; 94 name = "/i3/config";
95 temp = malloc(strlen(xdg_config_home) + strlen(name) + 1); 95 temp = malloc(strlen(xdg_config_home) + strlen(name) + 1);
96 strcpy(temp, home); 96 strcpy(xdg_config_home, home);
97 strcat(temp, name); 97 strcat(temp, name);
98 } 98 }
99 if (exists(temp)) { 99 if (exists(temp)) {
@@ -186,10 +186,9 @@ bool read_config(FILE *file, bool is_active) {
186 int temp_depth = 0; // Temporary: skip all config sections with depth 186 int temp_depth = 0; // Temporary: skip all config sections with depth
187 187
188 while (!feof(file)) { 188 while (!feof(file)) {
189 int _;
190 char *line = read_line(file); 189 char *line = read_line(file);
191 line = strip_whitespace(line, &_); 190 strip_comments(line);
192 line = strip_comments(line); 191 strip_whitespace(line);
193 if (!line[0]) { 192 if (!line[0]) {
194 goto _continue; 193 goto _continue;
195 } 194 }
diff --git a/sway/readline.c b/sway/readline.c
index be8c35cc..dfdc3fe8 100644
--- a/sway/readline.c
+++ b/sway/readline.c
@@ -3,7 +3,7 @@
3#include <stdio.h> 3#include <stdio.h>
4 4
5char *read_line(FILE *file) { 5char *read_line(FILE *file) {
6 int i = 0, length = 0, size = 128; 6 int length = 0, size = 128;
7 char *string = malloc(size); 7 char *string = malloc(size);
8 if (!string) { 8 if (!string) {
9 return NULL; 9 return NULL;
@@ -16,21 +16,20 @@ char *read_line(FILE *file) {
16 if (c == '\r') { 16 if (c == '\r') {
17 continue; 17 continue;
18 } 18 }
19 if (i == size) { 19 if (length == size) {
20 string = realloc(string, length *= 2); 20 string = realloc(string, size *= 2);
21 if (!string) { 21 if (!string) {
22 return NULL; 22 return NULL;
23 } 23 }
24 } 24 }
25 string[i++] = (char)c; 25 string[length++] = c;
26 length++;
27 } 26 }
28 if (i + 1 != size) { 27 if (length + 1 == size) {
29 string = realloc(string, length + 1); 28 string = realloc(string, length + 1);
30 if (!string) { 29 if (!string) {
31 return NULL; 30 return NULL;
32 } 31 }
33 } 32 }
34 string[i] = '\0'; 33 string[length] = '\0';
35 return string; 34 return string;
36} 35}
diff --git a/sway/stringop.c b/sway/stringop.c
index 1dff97bf..00cc32b8 100644
--- a/sway/stringop.c
+++ b/sway/stringop.c
@@ -1,37 +1,38 @@
1#include "stringop.h"
2#include <stdlib.h> 1#include <stdlib.h>
3#include <stdio.h> 2#include <stdio.h>
3#include <strings.h>
4#include <ctype.h>
5#include "stringop.h"
4#include "string.h" 6#include "string.h"
5#include "list.h" 7#include "list.h"
6#include <strings.h>
7 8
8/* Note: This returns 8 characters for trimmed_start per tab character. */ 9/* Note: This returns 8 characters for trimmed_start per tab character. */
9char *strip_whitespace(char *_str, int *trimmed_start) { 10void strip_whitespace(char *str) {
10 *trimmed_start = 0; 11 int shift = 0;
11 if (*_str == '\0') 12 int bpair = 1;
12 return _str; 13 int in_str = 0, in_ch = 0;
13 char *strold = _str; 14 while (*str) {
14 while (*_str == ' ' || *_str == '\t') { 15 str[-shift] = str[0];
15 if (*_str == '\t') { 16 if (*str == '"' && !in_ch) {
16 *trimmed_start += 8; 17 in_str = !in_str;
17 } else { 18 } else if (*str == '\'' && !in_str) {
18 *trimmed_start += 1; 19 in_ch = !in_ch;
20 } else if (!in_ch && !in_str) {
21 if (isblank(*str)) {
22 if (bpair) {
23 ++shift;
24 }
25 bpair=1;
26 } else {
27 bpair = 0;
28 }
19 } 29 }
20 _str++; 30 ++str;
21 } 31 }
22 char *str = malloc(strlen(_str) + 1); 32 str[-shift-bpair] = 0;
23 strcpy(str, _str);
24 free(strold);
25 int i;
26 for (i = 0; str[i] != '\0'; ++i);
27 do {
28 i--;
29 } while (i >= 0 && (str[i] == ' ' || str[i] == '\t'));
30 str[i + 1] = '\0';
31 return str;
32} 33}
33 34
34char *strip_comments(char *str) { 35void strip_comments(char *str) {
35 int in_string = 0, in_character = 0; 36 int in_string = 0, in_character = 0;
36 int i = 0; 37 int i = 0;
37 while (str[i] != '\0') { 38 while (str[i] != '\0') {
@@ -40,14 +41,13 @@ char *strip_comments(char *str) {
40 } else if (str[i] == '\'' && !in_string) { 41 } else if (str[i] == '\'' && !in_string) {
41 in_character = !in_character; 42 in_character = !in_character;
42 } else if (!in_character && !in_string) { 43 } else if (!in_character && !in_string) {
43 if (str[i] == '#' && i == 0) { 44 if (str[i] == '#') {
44 str[i] = '\0'; 45 str[i] = '\0';
45 break; 46 break;
46 } 47 }
47 } 48 }
48 ++i; 49 ++i;
49 } 50 }
50 return str;
51} 51}
52 52
53list_t *split_string(const char *str, const char *delims) { 53list_t *split_string(const char *str, const char *delims) {