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 = "";
|
||||
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.settings.exec-once = lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "init-hyprland";
|
||||
text = cfg.initExtraConfig;
|
||||
}
|
||||
);
|
||||
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 ./monitors.sh;
|
||||
}
|
||||
)
|
||||
} &";
|
||||
|
||||
wayland.windowManager.hyprland.settings.exec = lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "reload-hyprland";
|
||||
text = cfg.reloadExtraConfig;
|
||||
}
|
||||
);
|
||||
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;
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@@ -64,5 +64,7 @@ in
|
||||
};
|
||||
|
||||
theme.reloadExtraConfig = "${themeSwww} &";
|
||||
|
||||
wayland.windowManager.hyprland.onMonitorChange.services = [ "swww.service" ];
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user