{ config, pkgs, ... }:
{
  config.home.niri.settings.rules = pkgs.writeText "rules" ''
    // Browsers
    window-rule {
      match app-id="MainBrowser"
      open-on-workspace "${config.ws.w1}"
    }
    window-rule {
      match app-id="AltBrowser"
      open-on-workspace "${config.ws.w1a}"
    }

    // Gaming
    window-rule {
      match app-id="steam"
      open-on-workspace "${config.ws.w2}"
    }
    window-rule {
      match app-id="steam" title=r#"^notificationtoasts_\d+_desktop$"#
      default-floating-position x=10 y=10 relative-to="bottom-right"
    }
    
    // Communication
    window-rule {
      match app-id="MiscBrowser"
      match app-id="vesktop"
      block-out-from "screencast"
      open-maximized true
      open-on-workspace "${config.ws.w7}"
    }
    window-rule {
      match app-id="thunderbird"
      block-out-from "screencast"
      open-maximized true
      open-on-workspace "${config.ws.w9}"
    }

    // Etc
    window-rule {
      match app-id="com.obsproject.Studio"
      open-on-workspace "${config.ws.w4a}"
    }

    // Layer rules
    layer-rule {
      match namespace="^notifications$"
      block-out-from "screencast"
    }

    // Everything else
    screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"
    
    hotkey-overlay {
      skip-at-startup
    }
    
    environment {
      DISPLAY ":0"
    }
  '';
}
