]> git.lizzy.rs Git - bspwm.git/blob - README.md
Rewrite README
[bspwm.git] / README.md
1 ## Description
2
3 *bspwm* is a tiling window manager that represents windows as the leaves of a full binary tree.
4
5 It only responds to X events, and the messages it receives on a dedicated socket.
6
7 *bspc* is a program that writes messages on *bspwm*'s socket.
8
9 *bspwm* doesn't handle any keyboard or pointer inputs: a third party program (e.g. *sxhkd*) is needed in order to translate keyboard and pointer events to *bspc* invocations.
10
11 The outlined architecture is the following:
12
13 ```
14         PROCESS          SOCKET
15 sxhkd  -------->  bspc  <------>  bspwm
16 ```
17
18 ## Configuration
19
20 The default configuration file is `$XDG_CONFIG_HOME/bspwm/bspwmrc`: this is simply a shell script that calls *bspc*.
21
22 Keyboard and pointer bindings are defined with [sxhkd](https://github.com/baskerville/sxhkd).
23
24 Example configuration files can be found in the `examples` directory.
25
26 ## Monitors, desktops and windows
27
28 *bspwm* holds a list of monitors.
29
30 A monitor is just a rectangle that contains desktops.
31
32 A desktop is just a pointer to a tree.
33
34 Monitors only show the tree of one desktop at a time (their focused desktop).
35
36 The tree is a partition of a monitor's rectangle into smaller rectangular regions.
37
38 Each node in a tree either has zero or two children.
39
40 Each internal node is responsible for splitting a rectangle in half.
41
42 A split is defined by two parameters: the type (horizontal or vertical) and the ratio (a real number *r* such that *0 < r < 1*).
43
44 Each leaf node holds exactly one window.
45
46 ## Insertion Modes
47
48 ### Prelude
49
50 When *bspwm* receives a new window, it inserts it into a window tree at the specified insertion point (a leaf) using the insertion mode specified for that insertion point.
51
52 The insertion mode tells *bspwm* how it should alter the tree in order to insert new windows on a given insertion point.
53
54 By default the insertion point is the focused window and its default insertion mode is *automatic*.
55
56 ### Automatic Mode
57
58 The *automatic* mode, as opposed to the *manual* mode, doesn't require any user choice: the new window will *take the space* of the insertion point.
59
60 For example, let's consider the following scenario:
61
62 ```
63              a                          a                          a
64             / \                        / \                        / \
65            1   b         --->         1   c         --->         1   d
66               / \                        / \                        / \
67              2   3                      4   b                      5   c
68              ^                          ^  / \                     ^  / \
69                                           3   2                      b   4
70                                                                     / \ 
71                                                                    3   2
72
73  +-----------------------+  +-----------------------+  +-----------------------+
74  |           |           |  |           |           |  |           |           |
75  |           |     2     |  |           |     4     |  |           |     5     |
76  |           |     ^     |  |           |     ^     |  |           |     ^     |
77  |     1     |-----------|  |     1     |-----------|  |     1     |-----------|
78  |           |           |  |           |     |     |  |           |  3  |     |
79  |           |     3     |  |           |  3  |  2  |  |           |-----|  4  |
80  |           |           |  |           |     |     |  |           |  2  |     |
81  +-----------------------+  +-----------------------+  +-----------------------+
82
83               X                         Y                          Z 
84 ```
85
86 In state *X*, the insertion point, *2* is in automatic mode.
87
88 When we add a new window, *4*, the whole tree rooted at *b* is reattached, as the second child of a new internal node, *c*.
89
90 The splitting parameters of *b* (type: *horizontal*, ratio: *½*) are copied to *c* and *b* is rotated by 90° clockwise.
91
92 The tiling rectangle of *4* in state *Y* is equal to the tiling rectangle of *2* in state *X*.
93
94 Then the insertion of *5*, with *4* as insertion point, leads to *Z*.
95
96 The automatic mode generates window spirals that rotate clockwise (resp. anti-clockwise) if the insertion point is the first (resp. second) child of its parent.
97
98 ### Manual Mode
99
100 The user can specify a region in the insertion point where the next new window should appear by sending a *window --presel DIR* message to *bspwm*.
101
102 The *DIR* argument allows to specify how the insertion point should be split (horizontally or vertically) and if the new window should be the first or the second child of the new internal node (the insertion point will become its *brother*).
103
104 After doing so the insertion point goes into *manual* mode.
105
106 For example, let's consider the following scenario:
107
108 ```
109             a                          a                          a
110            / \                        / \                        / \
111           1   b         --->         c   b         --->         c   b
112           ^  / \                    / \ / \                    / \ / \
113             2   3                  4  1 2  3                  d  1 2  3
114                                    ^                         / \
115                                                             5   4
116                                                             ^
117
118 +-----------------------+  +-----------------------+  +-----------------------+
119 |           |           |  |           |           |  |     |     |           |
120 |           |     2     |  |     4     |     2     |  |  5  |  4  |     2     |
121 |           |           |  |     ^     |           |  |  ^  |     |           |
122 |     1     |-----------|  |-----------|-----------|  |-----------|-----------|
123 |     ^     |           |  |           |           |  |           |           |
124 |           |     3     |  |     1     |     3     |  |     1     |     3     |
125 |           |           |  |           |           |  |           |           |
126 +-----------------------+  +-----------------------+  +-----------------------+
127
128             X                          Y                          Z 
129 ```
130
131 In state *X*, the insertion point is *1*.
132
133 We send the following message to *bspwm*: *window --presel up*.
134
135 Then add a new window: *4*, this leads to state *Y*: the new internal node, *c* becomes *a*'s first child.
136
137 Finally we send another message: *window --presel left* and add window *5*.
138
139 The ratio of the preselection (that ends up being the ratio of the split of the new internal node) can be change with the *window --ratio* message.
140
141 ## Supported protocols and standards
142
143 - The RandR and Xinerama protocols.
144 - A subset of the EWMH and ICCCM standards.