OpenBSD Handbook

    Theme
    • Part I. Install & Configure
      • Introduction to OpenBSD
      • Installing OpenBSD
      • The X Window System
      • Networking on OpenBSD
      • System Configuration
      • OpenBSD Basics
      • Managing Software: Packages and Ports
    • Part II. Daily Operations
      • OpenBSD Desktop Environments
      • Multimedia
      • Printing
      • Linux Compatibility
      • Windows Compatibility
      • Games
    • Part III. System Administration
      • Virtualization
      • Storage and File Systems
      • Updating and Upgrading
      • Localization
      • The OpenBSD Boot Process
      • Security
    • Part IV. Networking & Daemons
      • Services
        • Database
          • MariaDB
          • PostgreSQL
          • Redis
          • memcached
        • Directory
          • YP (NIS)
          • LDAP
        • File
          • NFS
          • Samba
        • FTP Services
          • ftpd
          • ProFTPD
          • vsftpd
          • Pure-FTPd
          • TFTP
        • Mail
          • OpenSMTPD Mail Server
          • Dovecot IMAP and POP3 Server
          • Postfix
          • Exim
          • Rspamd
        • Name
          • Unbound DNS Resolver
          • NSD Authoritative DNS Server
          • BIND DNS Server
        • Networking
          • OpenBGPD
          • rad
          • DHCP on OpenBSD
          • slaacd
        • Web
          • Apache HTTP Server
          • nginx Web Server
          • OpenBSD httpd Web Server
          • relayd Reverse Proxy
        • Logging
          • syslogd
        • Monitoring
          • SNMP
        • Remote Access
          • Audit OpenSSH
          • OpenSSH Server
        • File Synchronization
          • rsync
        • Messaging
          • RabbitMQ Message Broker
        • Time
          • NTP Time Synchronization
      • PF
        • pfctl cheat sheet
        • PF Anchors
        • PF Filter Rules
        • PF Forwarding
        • PF Lists and Macros
        • PF Load Balancing
        • PF Logging
        • PF NAT
        • PF Options
        • PF Policies
        • PF Shortcuts
        • PF Tables
      • Advanced Networking
        • High Availability and State Replication
        • Multi-WAN and Policy-Based Routing
        • VPN and Cryptographic Tunneling
        • Classic and Lightweight Tunnels
        • IPv6 at Scale
        • QoS and Traffic Shaping
        • MPLS and Label Distribution
        • Network Services at Scale
        • Virtualization and Host Networking
        • Large-Scale L2 and L3 Design
        • Telemetry, Logging, and Flow Export
        • Hardening and Operational Safety
        • Reference Architectures
        • Troubleshooting Playbooks
      • Serial Communication
    • Part V. Miscellaneous
      • Virtualization Cheat Sheet
      • OpenBSD Cheatsheet
      • How-to Guides
        • Installation and First Boot
          • Complete the First 30 Minutes After Installation
          • Check Hardware Compatibility Before Installing
          • Bootstrap Wi-Fi Firmware Without Ethernet
          • Run OpenBSD as a Virtual Machine Guest
          • Install OpenBSD on a VPS or Cloud Server
          • Install OpenBSD with Full-Disk Encryption
          • Dual-Boot OpenBSD on a UEFI System
          • Automate OpenBSD Installation with Autoinstall and PXE
        • Desktops and Laptops
          • Set Up OpenBSD as a Laptop or Workstation
          • Configure Laptop Power Management
          • Troubleshoot Web Browsers on OpenBSD
          • Use Plan 9 Tools on OpenBSD
          • Build a Minimal Desktop with suckless Tools
          • Install Z shell (zsh)
        • Networking and Remote Access
          • Create an Administrator Account with doas and SSH Keys
          • Configure Secure Remote Access with OpenSSH
          • Use FIDO Security Keys with OpenSSH
          • Configure Wi-Fi Roaming and Wired Failover
          • Troubleshoot PF, NAT, and Routing
          • Route Multiple VLANs with PF
          • Configure a Road-Warrior WireGuard VPN
          • Route IPv6 Networks without NAT
          • Test OpenBGPD with Two Providers
          • Unlock an Internal Service with an SSH Key
          • Build a Simple Router and Firewall
        • Servers and Services
          • Set Up WordPress on OpenBSD
          • Build a Mail Server with OpenSMTPD, Dovecot, and Rspamd
        • Security, Maintenance and Recovery
          • Establish a Conservative Security Baseline
          • Recover Access and Reset the Root Password
          • Collect OpenBSD Diagnostic Evidence
          • Troubleshoot Package Installation and Update Failures
          • Schedule Recurring Maintenance
          • Monitor an OpenBSD System
          • Back Up and Restore an OpenBSD System
          • Configure softraid RAID1
          • Recover an OpenBSD System That Does Not Boot
        • Building, Automation and Virtual Machines
          • Manage OpenBSD with Ansible
          • Build Third-Party Software from Ports
          • Build OpenBSD from Source
          • Plan a Docker Workload Migration to OpenBSD
      • OpenBSD for Linux Users
      • OpenBSD for FreeBSD Users
      • OpenBSD for macOS Users
    • OpenBSD FAQ
    • OpenBSD Architectures
      • OpenBSD Package Search
        • Synopsis
        • Install the Tools
        • Start a dwm Session
        • Launch and Arrange Applications
        • Use st as a Terminal
        • Browse with surf
        • Lock the Display
        • Customize and Maintain the Setup
        • Return to the Previous Desktop

        Build a Minimal Desktop with suckless Tools

        Synopsis #

        This guide combines dwm for window management, dmenu for launching commands, st for a terminal, and surf for browsing. tabbed can contain several surf windows, and slock locks the display. The tools are independent: st, surf, and dmenu can also be used with OpenBSD’s base cwm(1) or another window manager.

        Begin with a working X session . Keep a copy of the existing session file so the previous desktop remains easy to restore. Use packaged tools first; source customization is optional.

        Install the Tools #

        doas pkg_add dwm dmenu st surf tabbed slock
        

        If package selection offers both plain st and a scrollback flavor, choose the desired variant. The plain version does not provide a terminal scrollback buffer; use a terminal multiplexer such as tmux(1) for scrollback, or select the packaged scrollback flavor.

        The small browser interface does not imply a small browser engine. surf depends on WebKitGTK and its supporting libraries. Keep it and its dependencies updated with the rest of the packages.

        Start a dwm Session #

        Save the existing ~/.xsession if it exists. For xenodm(1) , save the following as ~/.xsession:

        #!/bin/sh
        xsetroot -solid '#203040'
        xsetroot -name 'OpenBSD'
        exec /usr/local/bin/dwm
        

        Make it executable:

        chmod u+x ~/.xsession
        

        Log out and log in again. For startx(1), put the same script in ~/.xinitrc. Preserve the distinction between these two session files; see X session configuration .

        A minimal X session with dwm and dmenuAfter graphical login, xenodm runs the user's .xsession, which starts dwm. A keyboard shortcut opens dmenu to launch applications such as st and surf. The window manager arranges their windows; the launcher does not replace it.From login to applicationsxenodmGraphical login.xsessiondwmWindow layouts and tagsLauncher shortcutdmenustTerminalsurfWeb browserdwm arranges the application windows.
        The session starts dwm. Its launcher shortcut opens dmenu, which starts applications; dwm arranges their windows.

        Launch and Arrange Applications #

        The packaged defaults use Alt as the modifier. Configuration changes can alter these bindings.

        ShortcutAction
        Alt+Shift+ReturnOpen xterm, the packaged default terminal
        Alt+pOpen dmenu; type an application name and press Return
        Alt+j / Alt+kFocus the next or previous window
        Alt+ReturnPromote the selected window to the master area
        Alt+h / Alt+lChange the master area’s width
        Alt+1 through Alt+9View a tag
        Alt+Shift+1 through Alt+Shift+9Assign the selected window to a tag
        Alt+t / Alt+f / Alt+mSelect tiled, floating, or monocle layout
        Alt+Shift+cClose the selected application
        Alt+Shift+qQuit dwm and end this session

        Tags group windows. A window can belong to more than one tag, and more than one tag can be viewed at once. Start with one tag per task before adding more elaborate arrangements.

        To use st, press Alt+p, type st, and press Return. Installing st does not change dwm’s compiled terminal binding; changing that binding is an optional source customization.

        dwm tiles an st terminal and an editor beneath a bar showing tags and the selected layout.
        dwm gives the master window most of the width and stacks other windows beside it.

        Use st as a Terminal #

        Select a readable font when starting a terminal:

        st -f 'monospace:size=12'
        

        Select text with the mouse. Middle-click pastes the primary selection; Ctrl+Shift+c and Ctrl+Shift+v copy and paste through the clipboard. Test the font with the text and symbols actually used in the terminal. Font fallback depends on installed fonts.

        For scrollback with the plain package:

        st -e tmux
        

        Press Ctrl+b, then [ to enter tmux’s copy mode and inspect earlier output; q leaves copy mode. The terminal’s font and window options do not require rebuilding it. Use man 1 st for the terminal manual; st(4) describes tape devices.

        Browse with surf #

        Open a page from a terminal:

        surf https://www.openbsd.org/
        

        Ctrl+g opens URL entry through dmenu. Ctrl+h and Ctrl+l move backward and forward, and Ctrl+r reloads the page. Follow ordinary links with the mouse. Check surf(1) for the complete bindings and download behavior; surf does not provide the menus and download manager of a full browser.

        To contain browser windows in a tabbed interface:

        tabbed -c surf -e
        

        In tabbed, Ctrl+Shift+Return opens another tab. Ctrl+Shift+h and Ctrl+Shift+l switch to the previous and next tabs.

        A dwm session shows surf displaying a documentation page alongside an st terminal, with dmenu open across the top.
        dmenu launches commands; surf provides a browser window without a conventional toolbar.

        Keep another browser available when a site requires features or integrations absent from this setup. Do not disable certificate verification to make a site load.

        Lock the Display #

        Run the locker as the logged-in graphical user, from a terminal or dmenu:

        slock
        

        The display blanks while locked. Type the account password and press Return to unlock it. A color change indicates keyboard input or a failed attempt; there is no password dialog. Test locking and unlocking before relying on it. This command provides manual locking; it does not by itself configure idle or suspend locking.

        Customize and Maintain the Setup #

        The packaged defaults work without recompilation. Persistent changes to dwm’s key bindings and rules, and many defaults in other suckless tools, are compiled from config.h. Runtime command options still apply where the individual tool supports them.

        For source changes, use a release-matched ports tree and the ports build workflow . Keep the configuration change small, retain its patch, and rebuild a package rather than overwriting package-managed files with an unmanaged installation. Review that patch when updating to another version.

        The text displayed at the right of dwm’s bar comes from the root window name:

        xsetroot -name "$(date '+%a %H:%M')"
        

        This updates the bar once. A recurring status program is optional; start with the information actually needed.

        Return to the Previous Desktop #

        Restore the saved session file, then use Alt+Shift+q to quit dwm. The next graphical login uses the restored configuration. Close or save application work before ending the session.

        For login failures, inspect ~/.xsession-errors and verify the final executable in the session script. For application crashes, use the relevant browser diagnostics or package manual before adding patches.

        Report a bug
        • Synopsis
        • Install the Tools
        • Start a dwm Session
        • Launch and Arrange Applications
        • Use st as a Terminal
        • Browse with surf
        • Lock the Display
        • Customize and Maintain the Setup
        • Return to the Previous Desktop