{ config, pkgs, lib, ... }: let cfg = config.wayland.windowManager.hyprland; in { options.wayland.windowManager.hyprland = with lib; with types; { initExtraConfig = mkOption { type = lines; default = ""; description = "Extra configuration lines to add to exec-once"; }; reloadExtraConfig = mkOption { type = lines; default = ""; description = "Extra configuration lines to add to exec"; }; onMonitorChange.services = mkOption { type = listOf str; default = [ ]; description = "Services to restart when a monitor is connected or disconnected"; }; }; config = { wayland.windowManager.hyprland.initExtraConfig = lib.mkIf (cfg.onMonitorChange.services != [ ]) "${ lib.meta.getExe ( pkgs.writeShellApplication { name = "hyprland-monitor-change-services"; runtimeInputs = with pkgs; [ socat systemd ]; runtimeEnv.SERVICES = lib.strings.concatStringsSep " " cfg.onMonitorChange.services; text = builtins.readFile ./scripts/monitors.sh; } ) } &"; wayland.windowManager.hyprland.settings = { exec-once = lib.meta.getExe ( pkgs.writeShellApplication { name = "init-hyprland"; text = cfg.initExtraConfig; } ); exec = lib.meta.getExe ( pkgs.writeShellApplication { name = "reload-hyprland"; text = cfg.reloadExtraConfig; } ); }; }; }