/dwl-customization

dwm for Wayland

Primary LanguageCOtherNOASSERTION

README

This my dwl configuration (dwm for wayland).

Disclaimer: I do not know/use C and I barely know what I’m doing!

Overview

Every couple of years, I check if “wayland is ready” or more likely whether I’m ready for wayland.

The configuration is usable with a “modest” attempt to implement a ratpoison-like keybindings (Control+t prefix).

Patches

For the autostart patch, I apply changes from sevz17/dwl.

PatchPurpose
autostartRun programs on startup
keychordImplement ratpoison like keybindings
wayland-ipcIPC patch for status bar interactions

Keybindings

Key bindings are defined in config.def.h.

My initial idea was to adopt swhkd as hotkey daemon:

  • That would require writing a reasonably complete IPC implementation for interacting with dwl externally.
  • I don’t really like the fact that parts of swhkd need to run as root via pkexec, in comparison to sxhkd
  • swhkd does have a concept of “modes” (“keymaps”) which works well (tested with river and riverctl)

How to run it

I’m currently using dwlb as status bar.

dbus-run-session dwl -s "dwlb -ipc"

Programs invoked by my configuration include:

  • rclip: clipboard sharing between a host and virtual machines (patched for wayland)
  • foot: terminal emulator
  • swaylock: screen lock tool
  • bemenu: applications launcher menu

Screenshot

A new QEMU VM running Void Linux.

./screenshot.png

Optional setup for greetd

I use greetd with its gtkgreet graphical frontend under Void Linux.

In the commands to follow, I leverage doas instead of sudo (personal preference).

Install package dependencies

I execute gtkgreet via cage.

doas xbps-install -y cage greetd

Compile gtkgreet from sources and place its binary at /usr/local/bin/gtkgreet.

Add the greetd system user to various groups (_greeter user on Void Linux).

doas usermod -a -G input,video,_seatd _greeter

Display manager

Create a wrapper script at /usr/local/bin/gtkgreet-run.

#!/usr/bin/env bash

export XDG_RUNTIME_DIR=/tmp/greeter
export XDG_SESSION_TYPE=wayland
export XDG_CURRENT_DESKTOP=cage
export XDG_SESSION_DESKTOP=cage
export WLR_LIBINPUT_NO_DEVICES=1
export GDK_BACKEND=wayland
export WLR_NO_HARDWARE_CURSORS=1
export WLR_RENDERER_ALLOW_SOFTWARE=0

mkdir -p $XDG_RUNTIME_DIR

dbus-run-session cage -s -- gtkgreet

Ensure that the file is executable with doas chmod +x /usr/local/bin/gtkgreet-run.

Set the gtkgreet-run wrapper as greeter command in /etc/greetd/config.toml.

[terminal]
# The VT to run the greeter on. Can be "next", "current" or a number
# designating the VT.
vt = 7

# The default session, also known as the greeter.
[default_session]

# `agreety` is the bundled agetty/login-lookalike. You can replace `/bin/sh`
# with whatever you want started, such as `sway`.
# command = "agreety --cmd /bin/sh"
command = "/usr/local/bin/gtkgreet-run"

# The user to run the command as. The privileges this user must have depends
# on the greeter. A graphical greeter may for example require the user to be
# in the `video` group.
user = "_greeter"

Wrapper for launching wayland sessions

xinit equivalent

Create wrapper script at /usr/local/bin/startw.

#!/usr/bin/env sh

$SHELL -l -c "$HOME/.wayland-session"

Ensure that the file is executable with doas chmod +x /usr/local/bin/startw.

greetd registration

echo "startw" | doas tee -a /etc/greetd/environments

xinitrc equivalent

Note: I use ksh as login shell, adapt as needed.

Here are the contents of my $HOME/.wayland-session file.

#!/usr/bin/env ksh

. $HOME/.profile
. $HOME/.config/shell/kshrc

exec dbus-run-session dwl -s "dwlb -ipc"

Ensure that the file is executable with chmod +x ~/.wayland-session.