2023-11-22 15:33:16 -05:00
|
|
|
{
|
2023-12-04 10:05:25 -05:00
|
|
|
config,
|
2023-11-22 15:33:16 -05:00
|
|
|
lib,
|
2024-11-22 23:15:13 -05:00
|
|
|
mainUser,
|
2024-06-11 16:42:47 -04:00
|
|
|
pkgs,
|
|
|
|
self,
|
2023-11-22 15:33:16 -05:00
|
|
|
...
|
|
|
|
}: let
|
2024-11-21 11:26:08 -05:00
|
|
|
inherit (lib) concatStringsSep getExe removePrefix;
|
|
|
|
inherit (self.packages.${pkgs.system}) gpu-screen-recorder gsr-kms-server;
|
2024-06-27 01:03:50 -04:00
|
|
|
|
2024-06-11 16:42:47 -04:00
|
|
|
hyprPkgs = config.home-manager.users.${mainUser}.wayland.windowManager.hyprland.finalPackage;
|
2024-11-21 11:26:08 -05:00
|
|
|
|
|
|
|
cfgDesktop = config.roles.desktop;
|
2023-11-13 00:03:28 -05:00
|
|
|
in {
|
|
|
|
security.wrappers = {
|
|
|
|
gpu-screen-recorder = {
|
|
|
|
owner = "root";
|
|
|
|
group = "video";
|
|
|
|
capabilities = "cap_sys_nice+ep";
|
2024-11-21 11:26:08 -05:00
|
|
|
source = getExe gpu-screen-recorder;
|
2023-11-13 00:03:28 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
gsr-kms-server = {
|
|
|
|
owner = "root";
|
|
|
|
group = "video";
|
|
|
|
capabilities = "cap_sys_admin+ep";
|
2024-11-21 11:26:08 -05:00
|
|
|
source = getExe gsr-kms-server;
|
2023-11-13 00:03:28 -05:00
|
|
|
};
|
|
|
|
};
|
2023-12-04 10:05:25 -05:00
|
|
|
|
2024-01-09 13:13:04 -05:00
|
|
|
home-manager.users.${mainUser} = {
|
2024-05-05 23:07:06 -04:00
|
|
|
home.packages = [
|
|
|
|
(pkgs.writeShellApplication {
|
2024-02-16 16:41:10 -05:00
|
|
|
name = "gpu-save-replay";
|
2024-11-21 11:26:08 -05:00
|
|
|
|
|
|
|
runtimeInputs = with pkgs; [procps];
|
|
|
|
|
2024-02-16 16:41:10 -05:00
|
|
|
text = ''
|
|
|
|
pkill --signal SIGUSR1 -f gpu-screen-recorder
|
2024-01-08 11:25:18 -05:00
|
|
|
'';
|
2024-02-16 16:41:10 -05:00
|
|
|
})
|
|
|
|
|
2024-05-05 23:07:06 -04:00
|
|
|
(pkgs.writeShellApplication {
|
2024-02-16 16:41:10 -05:00
|
|
|
name = "gsr-start";
|
2024-11-21 11:26:08 -05:00
|
|
|
|
|
|
|
runtimeInputs = [
|
|
|
|
pkgs.pulseaudio
|
|
|
|
pkgs.xorg.xrandr
|
|
|
|
|
|
|
|
hyprPkgs
|
|
|
|
];
|
|
|
|
|
2024-02-16 16:41:10 -05:00
|
|
|
text = ''
|
2024-06-27 01:03:50 -04:00
|
|
|
main="${removePrefix "desc:" cfgDesktop.mainMonitor}"
|
2024-02-16 16:41:10 -05:00
|
|
|
WINDOW=$(hyprctl -j monitors | jq '.[] |= (.description |= gsub(","; ""))' | jq -r ".[] | select(.description | test(\"$main\")) | .name")
|
|
|
|
|
|
|
|
# Fix fullscreen game resolution
|
|
|
|
xrandr --output "$WINDOW" --primary
|
|
|
|
|
|
|
|
gpu-screen-recorder ${concatStringsSep " " [
|
2025-01-31 00:08:09 -05:00
|
|
|
# Prints fps and damage info once per second.
|
|
|
|
"-v no"
|
|
|
|
|
|
|
|
# Replay buffer time in seconds.
|
|
|
|
"-r 1200"
|
|
|
|
|
|
|
|
# Organise replays in folders based on the current date.
|
|
|
|
"-df yes"
|
|
|
|
"-o /home/matt/Videos/Replay"
|
|
|
|
|
|
|
|
# Audio codec to use.
|
|
|
|
"-ac aac"
|
|
|
|
|
|
|
|
# Audio device or application to record from (pulse audio device).
|
|
|
|
"-a desktop/default_output"
|
|
|
|
"-a microphone/default_input"
|
|
|
|
|
|
|
|
# Window id to record, display (monitor name), "screen", "screen-direct", "focused" or "portal".
|
|
|
|
"-w \"$WINDOW\""
|
|
|
|
|
|
|
|
# Frame rate to record at.
|
|
|
|
"-f 60"
|
|
|
|
|
|
|
|
# Container format for output file.
|
|
|
|
"-c mkv"
|
|
|
|
|
|
|
|
# Video codec to use.
|
|
|
|
"-k hevc"
|
2024-02-16 16:41:10 -05:00
|
|
|
]}
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
wayland.windowManager.hyprland.settings = {
|
2024-11-12 15:08:13 -05:00
|
|
|
bind = [",F8, exec, ags request 'save-replay'"];
|
2023-12-04 10:05:25 -05:00
|
|
|
};
|
|
|
|
};
|
2023-11-13 00:03:28 -05:00
|
|
|
}
|