{ lib, config, pkgs, ... }: with lib; let cfg = config.modules.software.system.wezterm; in { options.modules.software.system.wezterm = { enable = mkEnableOption "Enable wezterm, a blazingly fast terminal emulator"; package = mkOption { type = types.package; default = pkgs.wezterm; }; }; config = mkIf cfg.enable { environment.variables.TERM = "wezterm"; hm.programs.wezterm = { enable = true; package = cfg.package; extraConfig = let fonts = config.modules.desktop.fonts.fonts; in '' local wezterm = require 'wezterm' local act = wezterm.action local config = {} config.front_end = "WebGpu" config.font = wezterm.font '${fonts.monospaceBitmap.family}' config.font_size = ${toString fonts.monospaceBitmap.size} config.freetype_load_flags = 'MONOCHROME' config.enable_wayland = false config.use_fancy_tab_bar = false config.use_resize_increments = true config.initial_cols = 120 config.initial_rows = 40 config.window_background_opacity = 0.8 ${config.modules.desktop.themes.wezterm or ""} config.window_frame = { font = wezterm.font '${fonts.sansSerif.family}', font_size = ${toString fonts.sansSerif.size} } config.mouse_bindings = { -- Change the default click behavior so that it only selects -- text and doesn't open hyperlinks { event = { Up = { streak = 1, button = 'Left' } }, mods = 'NONE', action = act.CompleteSelection 'ClipboardAndPrimarySelection' }, -- and make CTRL-Click open hyperlinks { event = { Up = { streak = 1, button = 'Left' } }, mods = 'CTRL', action = act.OpenLinkAtMouseCursor }, -- Disable the 'Down' event of CTRL-Click to avoid weird program behaviors -- https://wezfurlong.org/wezterm/config/mouse.html#gotcha-on-binding-an-up-event-only { event = { Down = { streak = 1, button = 'Left' } }, mods = 'CTRL', action = act.Nop } } return config ''; }; }; }