• Stars
    star
    7,693
  • Rank 4,959 (Top 0.1 %)
  • Language
    C
  • License
    BSD 2-Clause "Sim...
  • Created over 12 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tiling window manager based on binary space partitioning

Description

bspwm is a tiling window manager that represents windows as the leaves of a full binary tree.

It only responds to X events, and the messages it receives on a dedicated socket.

bspc is a program that writes messages on bspwm's socket.

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.

The outlined architecture is the following:

        PROCESS          SOCKET
sxhkd  -------->  bspc  <------>  bspwm

Configuration

The default configuration file is $XDG_CONFIG_HOME/bspwm/bspwmrc: this is simply a shell script that calls bspc.

An argument is passed to that script to indicate whether is was executed after a restart ($1 -gt 0) or not ($1 -eq 0).

Keyboard and pointer bindings are defined with sxhkd.

Example configuration files can be found in the examples directory.

Monitors, desktops and windows

bspwm holds a list of monitors.

A monitor is just a rectangle that contains desktops.

A desktop is just a pointer to a tree.

Monitors only show the tree of one desktop at a time (their focused desktop).

The tree is a partition of a monitor's rectangle into smaller rectangular regions.

Each node in a tree either has zero or two children.

Each internal node is responsible for splitting a rectangle in half.

A split is defined by two parameters: the type (horizontal or vertical) and the ratio (a real number r such that 0 < r < 1).

Each leaf node holds exactly one window.

Insertion modes

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.

The insertion mode tells bspwm how it should alter the tree in order to insert new windows on a given insertion point.

By default the insertion point is the focused window and its insertion mode is automatic.

Manual mode

The user can specify a region in the insertion point where the next new window should appear by sending a node -p|--presel-dir DIR message to bspwm.

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).

After doing so the insertion point goes into manual mode.

Let's consider the following scenario:

            a                          a                          a
           / \                        / \                        / \
          1   b         --->         c   b         --->         c   b
          ^  / \                    / \ / \                    / \ / \
            2   3                  4  1 2  3                  d  1 2  3
                                   ^                         / \
                                                            5   4
                                                            ^

+-----------------------+  +-----------------------+  +-----------------------+
|           |           |  |           |           |  |     |     |           |
|           |     2     |  |     4     |     2     |  |  5  |  4  |     2     |
|           |           |  |     ^     |           |  |  ^  |     |           |
|     1     |-----------|  |-----------|-----------|  |-----------|-----------|
|     ^     |           |  |           |           |  |           |           |
|           |     3     |  |     1     |     3     |  |     1     |     3     |
|           |           |  |           |           |  |           |           |
+-----------------------+  +-----------------------+  +-----------------------+

            X                          Y                          Z 

In state X, the insertion point is 1.

We send the following message to bspwm: node -p north.

Then add a new window: 4, this leads to state Y: the new internal node, c becomes a's first child.

Finally we send another message: node -p west and add window 5.

The ratio of the preselection (that ends up being the ratio of the split of the new internal node) can be changed with the node -o|--presel-ratio message.

Automatic mode

The automatic mode, as opposed to the manual mode, doesn't require any user choice. The way the new window is inserted is determined by the value of the automatic scheme and the initial polarity settings.

Longest side scheme

When the value of the automatic scheme is longest_side, the window will be attached as if the insertion point was in manual mode and the split direction was chosen based on the dimensions of the tiling rectangle and the initial polarity.

Let's consider the following scenario, where the initial polarity is set to second_child:

             1                          a                          a
             ^                         / \                        / \
                         --->         1   2         --->         1   b
                                          ^                         / \
                                                                   2   3
                                                                       ^

 +-----------------------+  +-----------------------+  +-----------------------+
 |                       |  |           |           |  |           |           |
 |                       |  |           |           |  |           |     2     |
 |                       |  |           |           |  |           |           |
 |           1           |  |     1     |     2     |  |     1     |-----------|
 |           ^           |  |           |     ^     |  |           |           |
 |                       |  |           |           |  |           |     3     |
 |                       |  |           |           |  |           |     ^     |
 +-----------------------+  +-----------------------+  +-----------------------+

             X                          Y                          Z

In state X, a new window is added.

Since 1 is wide, it gets split vertically and 2 is added as a's second child given the initial polarity.

This leads to Y where we insert window 3. 2 is tall and is therefore split horizontally. 3 is once again added as b's second child.

Alternate scheme

When the value of the automatic scheme is alternate, the window will be attached as if the insertion point was in manual mode and the split direction was chosen based on the split type of the insertion point's parent and the initial polarity. If the parent is split horizontally, the insertion point will be split vertically and vice versa.

Spiral scheme

When the value of the automatic scheme is spiral, the window will take the space of the insertion point.

Let's dive into the details with the following scenario:

             a                          a                          a
            / \                        / \                        / \
           1   b         --->         1   c         --->         1   d
              / \                        / \                        / \
             2   3                      4   b                      5   c
             ^                          ^  / \                     ^  / \
                                          3   2                      b   4
                                                                    / \
                                                                   3   2

 +-----------------------+  +-----------------------+  +-----------------------+
 |           |           |  |           |           |  |           |           |
 |           |     2     |  |           |     4     |  |           |     5     |
 |           |     ^     |  |           |     ^     |  |           |     ^     |
 |     1     |-----------|  |     1     |-----------|  |     1     |-----------|
 |           |           |  |           |     |     |  |           |  3  |     |
 |           |     3     |  |           |  3  |  2  |  |           |-----|  4  |
 |           |           |  |           |     |     |  |           |  2  |     |
 +-----------------------+  +-----------------------+  +-----------------------+

             X                          Y                          Z

In state X, the insertion point, 2 is in automatic mode.

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.

The splitting parameters of b (type: horizontal, ratio: ½) are copied to c and b is rotated by 90° clockwise.

The tiling rectangle of 4 in state Y is equal to the tiling rectangle of 2 in state X.

Then the insertion of 5, with 4 as insertion point, leads to Z.

The spiral automatic scheme generates window spirals that rotate clockwise (resp. anti-clockwise) if the insertion point is the first (resp. second) child of its parent.

Supported protocols and standards

  • The RandR and Xinerama protocols.
  • A subset of the EWMH and ICCCM standards.

Community

Want to get in touch with other bspwm users or you need help? Join us on our:

More Repositories

1

sxhkd

Simple X hotkey daemon
C
2,755
star
2

plato

Document reader
Rust
1,258
star
3

xdo

Small X utility to perform elementary actions on windows
C
301
star
4

xtitle

Outputs X window titles
C
120
star
5

diana

A command line interface to the aria2 daemon
Python
112
star
6

bubblegum

A vim color scheme based on xoria256
Vim Script
88
star
7

shkd

Simple HotKey Daemon
C
72
star
8

xresources-color-schemes

Various Xresources Color Schemes
50
star
9

vim-sxhkdrc

Vim syntax for sxhkd's configuration files
Vim Script
49
star
10

sutils

Small command-line utilities
C
42
star
11

ciecam02

An implementation of CIECAM02
JavaScript
39
star
12

etc-linux

Configuration files
Vim Script
35
star
13

bin-linux

Various shell scripts
Python
34
star
14

fmon

File monitor
C
32
star
15

keydouble

A little X utility to enable the use of ordinary keys as modifiers
C
30
star
16

txtw

Return the pixel width of the given strings for the given font
C
29
star
17

xlsw

List the X window tree contents
C
26
star
18

Coal-Graal.tmTheme

A dark and lispy TextMate theme.
26
star
19

owlman

A pacman and cower wrapper
Shell
24
star
20

sketch

Draw sketches on e-paper
Rust
19
star
21

xqp

X Query pointer
C
19
star
22

sdunpack

Unpack a StarDict dictionary as plain text
Rust
18
star
23

paragraph-breaker

An implementation of the Knuth-Plass algorithm for breaking paragraphs into lines
Rust
17
star
24

sres

Print the current screen resolution on stdout
C
16
star
25

backlight

Get and set the backlight brightness
C
15
star
26

bin

Shell scripts
Shell
14
star
27

xwinfo

Print window informations
C
14
star
28

invisibone

Terminal color scheme
14
star
29

Common-Lisp.tmbundle

A Slimy Common Lisp TextMate bundle.
Perl
11
star
30

thmkit

Utilities aimed at producing homogeneous color themes
Python
11
star
31

sieve

Generates a palette from an image
Python
11
star
32

fdb

Path frecency database
Rust
10
star
33

etc

Configuration files
Vim Script
9
star
34

ewmhstatus

Outputs the current EWMH desktop name and window title
C
8
star
35

aco2gpl

Converts a Photoshop palette to a GIMP palette
C
7
star
36

Z

Fast terminal directory jumping
Go
7
star
37

homebrew-formulae

Homebrew formulae
Ruby
4
star
38

ciebase

Basic building blocks for CIE color spaces
JavaScript
4
star
39

hestia

A CLI Interface to the mldonkey Daemon
Python
3
star
40

stoic

Tiny static site generator
Python
3
star
41

baskerville.github.com

The Art of Baskerville
HTML
2
star
42

Flexible-Words-TextMate

A TextMate Plugin
Objective-C
2
star
43

SimpleIcons

Simple scalable grid based icon set
2
star
44

ledcns

Set the state of the keyboard LEDs
C
2
star
45

eat

A CLI interface to Ge.tt's API
Python
2
star
46

Inconsolata

Personal fork of Raph Levien's font
2
star
47

dmenu_qxyw

A patch for dmenu providing "width / offsets / quiet" options
1
star
48

PKGBUILDs

Arch Linux user packages
Shell
1
star
49

vim-quirks

Personal vim workarounds
Vim Script
1
star
50

vanisher

Mac OS X utility that hides the mouse pointer on demand
C
1
star