Add onMonitorChange hyprland hook script
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -39,5 +39,7 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wayland.windowManager.hyprland.onMonitorChange.services = [ "ags.service" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
8
hosts/common/configs/user/gui/hyprland/monitors.sh
Normal file
8
hosts/common/configs/user/gui/hyprland/monitors.sh
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
handle() {
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
case $1 in
|
||||||
|
monitoradded*|monitorremoved*) systemctl --user restart $SERVICES ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
socat -U - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do handle "$line"; done
|
@@ -23,21 +23,45 @@ in
|
|||||||
default = "";
|
default = "";
|
||||||
description = "Extra configuration lines to add to exec";
|
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 = {
|
config = {
|
||||||
wayland.windowManager.hyprland.settings.exec-once = lib.meta.getExe (
|
wayland.windowManager.hyprland.initExtraConfig =
|
||||||
pkgs.writeShellApplication {
|
lib.mkIf (cfg.onMonitorChange.services != [ ])
|
||||||
name = "init-hyprland";
|
"${
|
||||||
text = cfg.initExtraConfig;
|
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 ./monitors.sh;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} &";
|
||||||
|
|
||||||
wayland.windowManager.hyprland.settings.exec = lib.meta.getExe (
|
wayland.windowManager.hyprland.settings = {
|
||||||
pkgs.writeShellApplication {
|
exec-once = lib.meta.getExe (
|
||||||
name = "reload-hyprland";
|
pkgs.writeShellApplication {
|
||||||
text = cfg.reloadExtraConfig;
|
name = "init-hyprland";
|
||||||
}
|
text = cfg.initExtraConfig;
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
exec = lib.meta.getExe (
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "reload-hyprland";
|
||||||
|
text = cfg.reloadExtraConfig;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -64,5 +64,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
theme.reloadExtraConfig = "${themeSwww} &";
|
theme.reloadExtraConfig = "${themeSwww} &";
|
||||||
|
|
||||||
|
wayland.windowManager.hyprland.onMonitorChange.services = [ "swww.service" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user