Yazeed1s / zwm

X11 tiling window manager (work in progress)
BSD 2-Clause "Simplified" License
56 stars 1 forks source link
c linux window-manager x11 x11-wm xcb

zwm

About ZWM

zwm is a minimalistic and opinionated tiling window manager for X11. It uses XCB instead of Xlib to communicate with the X server. The underlying data structure for managing windows is a customized BSP tree.

Motivation

The motivation behind zwm stems from a desire to create a window manager that is both lightweight and highly efficient, yet tailored to how I like to work. Sure, there are other great tiling window managers that perform well and offer robust features, but zwm was developed primarily as a learning exercise in creating a window manager from scratch.

Goals

Features

The underlying data structure:

ZWM uses binary space partitioning tree (BSP-tree) to store and manage windows. This allows for more flexible layouts.

The following should illustrate how bsp-tree is used to achive window managment:

    Window and Partition Structure in a BSP-tree:

    The layout of windows in BSPWM follows a binary tree structure:

         I         ROOT (root is an INTERNAL NODE, unless it is a leaf by definition)
       /   \
      I     I      INTERNAL NODES (screen sections/partitions)
     / \   / \
    E   E E   E    EXTERNAL NODES (windows/leaves)

    - Internal Nodes (I) represent screen sections where windows can be displayed.
    - External Nodes (E) represent the actual windows within those sections.
    - Windows (E nodes) share the width, height, and coordinates (x, y) of their   parent sections (I nodes).

    Example Structure:

         I
       /   \
      I     I
     / \   / \
    E   E E   I
             / \
            E   E

    Partition Behavior:
    - Internal nodes (I) can contain other partitions or be contained within other partitions.
    - External nodes (E) are the leaves (actual windows).

    Example of tree:
    - 1, 2, 3 are leaves/windows (EXTERNAL_NODE).
    - a, b are internal nodes (INTERNAL_NODE), or screen sections/partitions.

            1                               a                          a
                                           / \                        / \
                            --->          1   2         --->         1   b
                                                                        / \
                                                                       2   3
    Visualization of Screen Layout:

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

    Another Example:
    - Numbers are the are leaves/windows (EXTERNAL_NODE).
    - Letters are internal nodes (INTERNAL_NODE), or screen sections/partitions.

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

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

Screenshots:

Installation

Arch Linux (AUR)

yay -S zwm

Build from source

Dependencies

As of now, the following configs are offered:

1- Config variables

border_width = 2
active_border_color = 0x83a598
normal_border_color = 0x30302f
window_gap = 10
virtual_desktops = 7
focus_follow_pointer = false
Available Variables:

2- Commands to run on startup

Use the exec directive to specify programs that should be started when ZWM is launched.

Default Keybindings

Key Description
super + w kill/close window
super + return launch a terminal (alacritty)
super + space launch dmenu
super + p launch rofi
super + [1..N] switche the desktop
super + l resize window (grow/expand)
super + h resize window (shrink)
super + f toggle fullscreen
super + shift + [1..N] transfer window to a diff desktop
super + shift + m toggle master layout
super + shift + s toggle stack layout
super + shift + d toggle default layout
super + shift + j/k traverse the stack
super + shift + f flip the window/partion
super + shift + r hot-reload
super + s swap window's orientation
super + ← focus window on the left
super + ↑ focus window above
super + → focus window on the right
super + ↓ focus window below
super + shift + → cycle desktop right
super + shift + ← cycle desktop left

ewmh specific settings for polyabr

To display the window name (CLASS_NAME):

[module/xwindow]
type            = internal/xwindow
format          = <label>
; Available tokens:
;   %title%
;   %instance% (first part of the WM_CLASS atom, new in version 3.7.0)
;   %class%    (second part of the WM_CLASS atom, new in version 3.7.0)
; Default: %title%
label       = %title%
label-maxlen    = 50
label-empty     = "[null]"

To display workspaces:

[module/ewmh]
type = internal/xworkspaces
label-active            = %index%
label-active-background     = ${colors.bg}
label-active-underline      = ${colors.blue}
label-active-padding        = 1
label-occupied          = %index%
label-occupied-padding      = 1
label-urgent            = %index%!
label-urgent-background     = ${colors.red}
label-urgent-padding        = 1
label-empty             = %index%
label-empty-foreground      = ${colors.gray}
label-empty-padding         = 1
label-separator         = " "

For further custmization please refer to polybar's wiki.

Contributing

If you would like to add a feature or to fix a bug please feel free to submit a PR.