Skip to content

volh/dwl-janet

Repository files navigation

dwl-janet

A fork of dwl with Janet scripting.

dwl-janet lets you configure your Wayland compositor with a Lisp instead of recompiling C. Edit your config, save, and changes apply instantly.

Features

  • Hot-reload: Config reloads automatically when you save
  • Janet scripting: Keybindings, layouts, and actions in a Clojure-like Lisp
  • Custom layouts: Write tiling layouts as Janet functions
  • Everything else from dwl: Tags, master-stack tiling, multi-monitor, wlroots-based

Building

Dependencies:

  • libinput
  • wayland
  • wlroots (compiled with the libinput backend)
  • xkbcommon
  • wayland-protocols (compile-time only)
  • pkg-config (compile-time only)

dwl has the following additional dependencies if XWayland support is enabled:

  • libxcb
  • libxcb-wm
  • wlroots (compiled with X11 support)
  • Xwayland (runtime only)

Install these (and their -devel versions if your distro has separate development packages) and run make.

To enable XWayland, uncomment the flags in config.mk.

Configuration

dwl-janet looks for config.janet in these locations (in order):

  1. $XDG_CONFIG_HOME/dwl/config.janet
  2. ~/.config/dwl/config.janet
  3. ./config.janet (current directory, for development)

Hot-reload

The config file is automatically reloaded when saved. No restart needed.

What you can configure in Janet

  • Keybindings: Define all keyboard shortcuts in Janet
  • Layouts: Write custom tiling layouts as Janet functions
  • Actions: spawn programs, focus windows, manage tags, etc.

Example config.janet

# Import dwl functions
(def spawn (in dwl :spawn))
(def bind-key (in dwl :bind-key))
(def focus-stack (in dwl :focus-stack))

# Modifier keys
(def MOD-LOGO 64)  # Super key

# Keysyms
(def XK-Return 0xff0d)
(def XK-j 0x006a)

# Keybindings
(bind-key MOD-LOGO XK-Return (fn [] (spawn "kitty")))
(bind-key MOD-LOGO XK-j (fn [] (focus-stack 1)))

See config.janet for a complete example with layouts and all keybindings.

Available dwl functions

Function Description
(dwl :spawn) Spawn a program
(dwl :bind-key) Register a keybinding
(dwl :focus-stack) Focus next/prev window
(dwl :set-mfact) Adjust master area size
(dwl :inc-nmaster) Change number of masters
(dwl :kill-client) Close focused window
(dwl :toggle-floating) Toggle floating mode
(dwl :toggle-fullscreen) Toggle fullscreen
(dwl :view) Switch to tag
(dwl :tag) Move window to tag
(dwl :set-layout) Set layout by symbol
(dwl :resize) Resize a client (for layouts)
(dwl :log) Print to stderr

Writing custom layouts

Layouts are Janet functions that receive monitor info and a list of clients:

(defn my-layout [mon clients]
  (each c clients
    (resize (c :ptr)
            (mon :x) (mon :y)
            (mon :width) (mon :height))))

See config.janet for examples: tile, monocle, grid, centered-master, spiral.

Running

dwl-janet can run nested inside an existing Wayland or X11 session (useful for testing), or directly from a VT console.

# Nested (for testing)
./dwl

# With a startup script
dwl -s 'waybar <&-'

For running from a VT, you may need to add yourself to video and input groups, or use elogind/systemd-logind with polkit.

Status bar

Status info (tags, layout, window title) is written to the -s command's stdin. Use <&- to close stdin if your startup command doesn't consume it.

Credits

dwl-janet is a fork of dwl, which was created by Devin J. Pohly and built on wlroots.

Janet scripting integration by Claude Code.

License

See LICENSE files in the repository.

About

No description, website, or topics provided.

Resources

License

Unknown and 3 other licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE.dwm
MIT
LICENSE.sway
Unknown
LICENSE.tinywl

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages