Jump to content

dwl

From ArchWiki

dwl is the wlroots-based fork of the suckless window manager dwm created for Wayland users.

Installation

dwl can be installed with the dwlAUR or dwl-gitAUR packages. Make any required configuration changes before building and installing, see makepkg.

Tip: Upstream instructions can also be followed, but will install files without having pacman keeping track of them.

Configuration

dwl is configured at compile-time by editing some of its source files, specifically config.h. For detailed information on these settings, see the included, well-commented config.def.h

The official website has a number of patches that can add extra functionality to dwl. These patches primarily make changes to the dwl.c file but also make changes to the config.h file where appropriate. For information on applying patches, see the Patching packages article.

Enable XWayland

To build dwl with XWayland enabled, install xorg-xwayland and uncomment the following lines in the config.mk file:

# Uncomment to build XWayland support
XWAYLAND = -DXWAYLAND
XLIBS = xcb xcb-icccm

Starting

Select Dwl from the menu in a display manager of choice.

You can also autostart a command using the -s flag. This command will have information about selected layouts, current window title, app-id, and tags written to it's stdin by dwl. You can use this to populate your status bar. If your command does not consume the data sent by dwl, append <&- to it like this:

dwl -s 'sh /path/to/autostart.sh <&-'

Usage

See the dwl tutorial for information on basic dwl usage.

Tips and tricks

WebRTC screen sharing

install xdg-desktop-portal-wlr and xdg-desktop-portal-gtk

then in ~/.config/xdg-desktop-portal/


portals.conf
[preferred]
default=gtk
org.freedesktop.impl.portal.Screenshot=wlr
org.freedesktop.impl.portal.ScreenCast=wlr 

then restart


you change a setting or update the dwl code base.



Floating layout for some windows

For some windows, such as preferences dialogs, it does not make sense for these windows to be tiled - they should be free-floating instead. For example, to make Firefox's preferences dialog float, add the following to your rules array in config.h:

{ "Firefox",     NULL,       "Firefox Preferences",        1 << 8,         True,     -1 },

Taking screenshots

Install the grim package. Next create two scripts:

/path/to/scripts/screenshot.sh
#!/bin/sh
mkdir -p /path/to/pics && grim /path/to/pics/%m-%d-%Y-%H%M%S.png

for making screenshots and

/path/to/scripts/screenshotsel.sh
#!/bin/sh
mkdir -p /path/to/pics && grim /path/to/pics/%m-%d-%Y-%H%M%S.png --select --line mode=edge

for making screenshots with a selection box. Give them executable permissions. In config.h add the following:

static const Key keys[] = {
       ...
       
       { 0,         XKB_Print, spawn, SHCMD("/path/to/scripts/screenshot.sh") },
       { ShiftMask, XKB_Print, spawn, SHCMD("/path/to/scripts/screenshotsel.sh") },
       
       ...
};

This maps taking screenshots to the print key and taking screenshots with a selection box to the shift + print keys.

Adjusting volume

Install the pipewire package. Now in config.h we may add commands for mute and volume increase/decrease.

static const char *up_vol[]   = { "pactl", "set-sink-volume", "@DEFAULT_SINK@", "+10%",   NULL };
static const char *down_vol[] = { "pactl", "set-sink-volume", "@DEFAULT_SINK@", "-10%",   NULL };
static const char *mute_vol[] = { "pactl", "set-sink-mute",   "@DEFAULT_SINK@", "toggle", NULL };
...

static const Key keys[] = {
       ...
       
       { 0, XF86XK_AudioMute,        spawn, {.v = mute_vol } },
       { 0, XF86XK_AudioLowerVolume, spawn, {.v = down_vol } },
       { 0, XF86XK_AudioRaiseVolume, spawn, {.v = up_vol } },
       
       ... 
};

Autostart

A patch is available. It runs autostart array in your config.h

Troubleshooting

Fixing misbehaving Java applications

See Java#Gray window, applications not resizing with WM, menus immediately closing.

Fixing gaps around terminal windows

If there are empty gaps of desktop space outside terminal windows, it is likely due to the terminal's font size. Either adjust the size until finding the ideal scale that closes the gap, or toggle resizehints to 0 in config.h.

This will cause dwl to ignore resize requests from all client windows, not just terminals. The downside to this workaround is that some terminals may suffer redraw anomalies, such as ghost lines and premature line wraps, among others.

Alternatively, if you use the st terminal emulator, you can apply the anysize patch and recompile st.


See also