// ─────────────────────────────────────────────────────────────────────────────
// modules/environment.kdl — Environment variables and cursor settings
//
// PURPOSE: Sets environment variables that niri injects into every child
//          process it spawns (applications, autostart commands, etc.).
//          Also configures the hardware cursor appearance and auto-hide behaviour.
//
// NOTE: Variables set here apply to the compositor's process tree.  They will
//       NOT retroactively affect processes already running before niri started.
// ─────────────────────────────────────────────────────────────────────────────

// ── Environment Variables ─────────────────────────────────────────────────────
environment {
    // GTK_THEME: Tell GTK 3/4 applications which theme to load.
    // WHY "cyberqueer": ensures every GTK app adopts the custom dark+pink palette
    // without requiring each app to be individually configured.
    GTK_THEME "cyberqueer"

    // XCURSOR_SIZE: Hardware cursor icon size in pixels.
    // WHY 40: on a HiDPI display at 2× scale, 40 CSS-pixels = 80 physical pixels,
    // which renders at a readable size without being distractingly large.
    XCURSOR_SIZE "40"

    // XCURSOR_THEME: Name of the XCursor theme for the pointer icon set.
    // "Nordzy-cursors-lefthand" is the left-handed variant of the Nordzy cursor
    // theme.  WHY left-handed: the primary user is left-handed.
    XCURSOR_THEME "Nordzy-cursors-lefthand"

    // QT_QPA_PLATFORMTHEME: Instruct Qt apps to use the GTK 3 platform theme
    // plugin, so Qt dialogs inherit GTK colours and font settings.
    // WHY: without this, Qt apps use a default Fusion style that clashes with
    // the cyberqueer colour palette.
    QT_QPA_PLATFORMTHEME "gtk3"

    // QT_WAYLAND_DISABLE_WINDOWDECORATION: Tell Qt to suppress client-side
    // title bars on Wayland (rely on the compositor's server-side decorations).
    // WHY: consistent with prefer-no-csd in config.kdl; prevents double borders.
    QT_WAYLAND_DISABLE_WINDOWDECORATION "1"

    // MOZ_ENABLE_WAYLAND: Force Firefox/Thunderbird to use the native Wayland
    // backend instead of falling back to XWayland.
    // WHY: native Wayland gives better performance, correct HiDPI scaling, and
    // proper fractional scaling support.
    MOZ_ENABLE_WAYLAND "1"

    // ELECTRON_OZONE_PLATFORM_HINT: Hint Electron apps (VSCode, Discord, etc.)
    // to auto-select the Wayland Ozone backend when running under Wayland.
    // "auto" lets Electron decide; it chooses Wayland when $WAYLAND_DISPLAY is set.
    ELECTRON_OZONE_PLATFORM_HINT "auto"

    // NIXOS_OZONE_WL: Compatibility variable recognised by Electron apps packaged
    // for NixOS to activate Wayland Ozone.  Harmless on non-NixOS systems; included
    // so Flatpak/AUR Electron packages that check this also opt into Wayland.
    NIXOS_OZONE_WL "1"

    // GDK_SCALE: Global integer scale factor for GTK 3/4 applications.
    // WHY 2: matches the display's 2× HiDPI scale so UI elements are not blurry.
    // Note: this is an integer scale; fractional scaling is handled separately
    // by the Wayland output configuration in outputs.kdl.
    GDK_SCALE "2"
}

// ── Cursor ────────────────────────────────────────────────────────────────────
cursor {
    // xcursor-theme: compositor-level cursor theme (overrides the env var above
    // for the pointer rendered by niri itself, not just child processes).
    xcursor-theme "Nordzy-cursors-lefthand"

    // xcursor-size: cursor size at compositor level, matching XCURSOR_SIZE above.
    xcursor-size 40

    // hide-after-inactive-ms: automatically hide the cursor after 5 seconds of
    // no mouse movement.  WHY: reduces visual clutter during reading or video.
    hide-after-inactive-ms 5000

    // hide-when-typing: immediately hide the cursor when a key is pressed.
    // WHY: removes the cursor from the field of view while typing so it doesn't
    // obscure text — restored as soon as the mouse moves again.
    hide-when-typing
}
