Customizing FancyWM — Themes, Rules, and Keybindings

Customizing FancyWM — Themes, Rules, and KeybindingsFancyWM is a modern, configurable tiling window manager designed for users who want both aesthetics and productivity. It provides a lightweight core with powerful customization hooks: theming for appearance, rule systems for window behavior, and flexible keybinding configuration for fast, keyboard-driven workflows. This article walks through practical steps and examples to customize FancyWM’s look and behavior, from picking a theme and writing rules to composing keybindings and automations.


Table of contents

  • Why customize FancyWM?
  • Where FancyWM stores configuration
  • Theming: colors, fonts, and layout
  • Rules: matching windows and setting behavior
  • Keybindings: structure, modifiers, and examples
  • Advanced tips: scripts, startup, and plugins
  • Troubleshooting and best practices

Why customize FancyWM?

Customizing FancyWM lets you:

  • Reduce friction by tailoring window behavior to your workflow.
  • Improve readability and focus through thoughtfully chosen themes.
  • Automate repetitive actions with rules and keybindings.
  • Keep your environment consistent across machines by storing configurations as code.

Where FancyWM stores configuration

FancyWM’s configuration is typically a single declarative file plus optional supplementary scripts:

  • Primary config: ~/.config/fancywm/config.{lua,ts,or toml} (format depends on your FancyWM build)
  • Theme files: ~/.config/fancywm/themes/
  • Rule files: ~/.config/fancywm/rules/
  • Keybinding scripts: ~/.config/fancywm/bin/

Back up this directory before making big changes. Use a dotfiles repo to track changes.


Theming: colors, fonts, and layout

Themes define the visual language of your desktop: colors, spacing, borders, and fonts.

Example theme structure (conceptual)

  • colors: background, foreground, accent, urgent
  • borders: width, radius, color
  • fonts: primary, fallback
  • gaps: inner and outer gaps between windows
  • status bar: height, icon set, alignment

Sample theme (pseudo-code)

theme = {   colors = {     bg = "#0f1117",     fg = "#cbd5e1",     accent = "#7c3aed",     urgent = "#ef4444",   },   border = { width = 2, focus = "#7c3aed", normal = "#111827" },   font = "Inter Regular 11",   gaps = { inner = 8, outer = 12 },   bar = { height = 28, padding = 6, align = "center" }, } 

Practical tips

  • Pick a high-contrast accent color for focused windows and notifications.
  • Use a variable-pitch font for apps that use many UI elements, and a monospace for terminals.
  • Tune inner/outer gaps for visibility vs. screen real estate.

Rules: matching windows and setting behavior

Rules let you control how windows appear and behave (floating, workspace assignment, geometry).

Common match criteria

  • class (WM_CLASS)
  • title (window title)
  • role (WM_ROLE)
  • type (dialog, normal)
  • instance (specific process instance)

Example rules (pseudo-code)

rules = {   { match = { class = "Firefox" },   workspace = "2:web",  floating = false },   { match = { class = "Gimp" },      workspace = "5:media", floating = true,  center = true },   { match = { type = "dialog" },     floating = true,  focus = true },   { match = { class = "Alacritty" }, workspace = "1:term",  floating = false, toggle_fullscreen = true }, } 

Best practices

  • Assign web browsers and chat apps to designated workspaces.
  • Float dialogs and VMs by default.
  • Use title or role matches sparingly — they can be brittle after updates.

Keybindings: structure, modifiers, and examples

Keybindings are how you interact quickly with FancyWM. A robust set includes workspace switching, window management, launching applications, and media controls.

Common modifier keys

  • Mod (often Super/Win)
  • Shift
  • Control
  • Alt (Mod1)

Example keybinding layout (pseudo-code)

keys = {   -- Launchers   { mods = {"Mod"},      key = "Return", action = "spawn('alacritty')" },   { mods = {"Mod"},      key = "d",      action = "spawn('rofi -show drun')" },   -- Window focus and movement   { mods = {"Mod"},      key = "h",      action = "focus('left')" },   { mods = {"Mod","Shift"}, key = "h",   action = "move('left')" },   -- Layout toggles   { mods = {"Mod"},      key = "space",  action = "cycle_layout()" },   -- Workspace management   { mods = {"Mod"},      key = "1",      action = "view_workspace('1')" },   { mods = {"Mod","Shift"}, key = "1",   action = "move_to_workspace('1')" },   -- System   { mods = {"Mod"},      key = "b",      action = "toggle_bar()" }, } 

Ergonomics tips

  • Keep frequently used actions on easy-to-reach keys (e.g., Mod + Enter, Mod + h/j/k/l).
  • Use consistent modifiers for grouped actions: Mod for navigation, Mod+Shift for moving windows.
  • Add a “scratchpad” terminal keybinding for quick commands.

Advanced tips: scripts, startup, and plugins

Startup automation

  • Use an autostart script to set background, start status bar, restore wallpaper, and launch key services.
  • Example: ~/.config/fancywm/autostart.sh
    • set wallpaper (swaybg/feh)
    • start status bar (waybar/polybar)
    • start compositor (picom)
    • restore clipboard manager (clipit)

Scripting and IPC

  • Use FancyWM’s IPC (if available) to script dynamic layouts, gap toggles, or workspace renaming.
  • Example: a small script that toggles gaps when a fullscreen app is detected.

Plugins and extensions

  • Check the FancyWM plugin registry for extra layout algorithms, widgets, or rule helpers.
  • Keep plugins minimal to avoid slowing startup.

Troubleshooting and best practices

  • Test changes incrementally; keep a working console session to revert configs.
  • Use verbose logging to diagnose rule matches and keybinding conflicts.
  • Keep a fallback config that launches a basic TTY or another WM in case of errors.
  • Share configs in a dotfiles repo and add comments for clarity.

Customizing FancyWM lets you shape both the look and the behavior of your desktop to match how you think and work. Start small—theme tweaks and a few keybindings—then add rules and scripts as your workflow solidifies.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *