今天就切换到平铺式窗口管理器吧!
Switch to a tiling-window-manager TODAY

原始链接: https://github.com/uint23/sxwm

sxwm 是一款轻量、快速且可配置的窗口管理器,仅需 libX11 和 Xinerama 即可运行。它提供平铺和浮动布局,九个集成工作区,并支持通过用户友好的 `~/.config/sxwmrc` 文件实时重新加载配置。主要功能包括受 DWM 启发的主窗格布局、鼠标窗口操作支持以及 Xinerama 多显示器支持。 配置选项包括设置修饰键、间隙、边框宽度、颜色、主窗格宽度百分比以及用于更平滑鼠标操作的运动节流。可以轻松定义键绑定,用于外部命令和内部功能,例如窗口管理、工作区切换和间隙调整。文中给出了启动终端、关闭窗口和在工作区之间移动等常见操作的键绑定示例。文档还提供了使用 GCC 或 Clang 的简单构建和安装说明。

16岁的开发者uint23在Hacker News上发帖推广其在GitHub上托管的窗口平铺管理器sxwm。他们将sxwm描述为一个易于配置、未经修改且轻量级的替代方案,可以替代现有的DWM和i3等窗口平铺管理器。uint23声称sxwm的代码行数(LOC)比DWM少。 这篇文章引发了一些讨论。一位用户ed_mercer提到在尝试了i3和Hyprland之后,想念macOS的UI。其他人则质疑uint23将DWM描述为不完整,将i3描述为臃肿的说法,并质疑为什么代码行数少于DWM对于最终用户来说一定是一个优点。

原文

  • Tiling & Floating: Switch seamlessly between layouts.
  • Workspaces: 9 workspaces, fully integrated with your bar.
  • Live Config Reload: Change your config and reload instantly with a keybind.
  • Easy Configuration: Human-friendly sxwmrc file, no C required.
  • Master-Stack Layout: Productive, DWM-inspired workflow.
  • Mouse Support: Move, swap, resize, and focus windows with the mouse.
  • Zero Dependencies: Only libX11 and Xinerama required.
  • Lightweight: Single C file, minimal headers, compiles in seconds.
  • Bar Friendly: Works great with sxbar.
  • Xinerama Support: Multi-monitor ready.
  • Fast: Designed for speed and low resource usage.



Click to expand
  • NEW: Using XCursor instead of cursor font && new logo.
  • FIXED: Proper bind resetting on refresh config. && Multi-arg binds now work due to new and improved spawn function
  • CHANGE: No longer using INIT_WORKSPACE macro, proper workspace handling. New sxwmrc
  • CHANGE: Added motion throttle && master width general options
  • CHANGE: ulong, u_char uint are gone
  • NEW: Parser support
  • FIXED: Quit syntax && Freeing cursor on exit
  • NEW: Xinerama support, swap windows with Mod + Shift + Drag
  • FIXED: New windows in global_floating mode spawn centered

Configuration (~/.config/sxwmrc)

sxwm is configured via a simple text file located at ~/.config/sxwmrc. Changes can be applied instantly by reloading the configuration (default keybind: MOD + r).

The file uses a key : value format. Lines starting with # are ignored.

Option Type Default Description
mod_key String super Sets the primary modifier key (alt, super, ctrl).
gaps Integer 10 Pixels between windows and screen edges.
border_width Integer 1 Thickness of window borders in pixels.
focused_border_colour Hex #c0cbff Border color for the currently focused window.
unfocused_border_colour Hex #555555 Border color for unfocused windows.
swap_border_colour Hex #fff4c0 Border color highlight when selecting a window to swap with (MOD+Shift+Drag).
master_width Integer 60 Percentage (%) of the screen width the master window should occupy.
resize_master_amount Integer 1 Percentage (%) to increase/decrease the master width when resizing.
snap_distance Integer 5 Pixels from screen edge before a floating window snaps to the edge.
motion_throttle Integer 60 Target updates per second for mouse drag operations (move/resize/swap). Set close to your monitor's refresh rate for smoother visuals.

Keybindings associate key combinations with actions (either running external commands or internal sxwm functions).

Syntax:

bind : [modifier + modifier + ... + key] : action
  • bind: Keyword to define a keybinding.
  • [...]: Contains the key combination.
    • Modifiers: mod (uses the key set by mod_key), shift, ctrl, alt, super. Use + to combine multiple modifiers.
    • key: The final key name (e.g., Return, q, 1, equal, space). Key names generally follow X11 keysym names but are case-insensitive in the config.
  • :: Separator.
  • action:
    • Command: An external command enclosed in double quotes ("). Arguments are separated by spaces (e.g., "st -e vim").
    • Function: The name of an internal sxwm function (see list below).

Available Functions:

Function Name Action
close_window Closes the currently focused window.
decrease_gaps Decreases the gap size between windows.
focus_next Shifts focus to the next window in the stack/list.
focus_previous Shifts focus to the previous window in the stack/list.
increase_gaps Increases the gap size between windows.
master_next Moves the focused window down the master/stack order.
master_previous Moves the focused window up the master/stack order.
quit Exits sxwm.
reload_config Reloads the sxwmrc configuration file.
master_increase Increases the width allocated to the master area.
master_decrease Decreases the width allocated to the master area.
toggle_floating Toggles the floating state of the focused window.
global_floating Toggles the floating state for all windows on the current workspace.
fullscreen Toggles fullscreen mode for the focused window.
change_ws[1-9] Switches focus to the specified workspace (1-9).
moveto_ws[1-9] Moves the focused window to the specified workspace (1-9).

Example Bindings:

# Launch terminal with Mod + Enter
bind : [mod + Return] : "st"

# Close focused window with Mod + Shift + Q
bind : [mod + shift + q] : close_window

# Switch to workspace 3 with Mod + 3
bind : [mod + 3] : change_ws3

# Move focused window to workspace 5 with Mod + Shift + 5
bind : [mod + shift + 5] : moveto_ws5

Combo Action
Mouse Focus under cursor
MOD + Left Mouse Move window by mouse
MOD + Right Mouse Resize window by mouse
MOD + j / k Focus next / previous
MOD + Shift + j / k Move in master stack
MOD + Space Toggle floating
MOD + Shift + Space Toggle all floating
MOD + = / - Increase/Decrease gaps
MOD + f Fullscreen toggle
MOD + q Close focused window
MOD + 1-9 Switch workspace 1–9
MOD + Shift + 1-9 Move window to WS 1–9
Combo Action Program
MOD + Return Terminal st
MOD + b Browser firefox
MOD + p Launcher dmenu_run

  • libX11 (Xorg client library)
  • Xinerama
  • GCC or Clang & Make

git clone --depth=1 https://github.com/uint23/sxwm.git
cd sxwm/
make
sudo make clean install

Add to your ~/.xinitrc:


Target Description
make / make all Build the sxwm binary
make clean Remove object files and build artifacts
make install Install sxwm to $(PREFIX)/bin (default /usr/local/bin)
make uninstall Remove the installed binary
make clean install Clean and then install

Override install directory with PREFIX or DESTDIR:

make install PREFIX=$HOME/.local

  • dwm — Tiling & source code
  • i3 — Easy configuration
  • sowm — README inspiration
  • tinywm — Minimal X11 WM

Contributions welcome! Open issues or submit PRs.

联系我们 contact @ memedata.com