nixos-configs/devices/binto/modules/gpu-replay.nix

88 lines
2.1 KiB
Nix
Raw Normal View History

2023-11-22 15:33:16 -05:00
{
config,
2023-11-22 15:33:16 -05:00
lib,
pkgs,
self,
2023-11-22 15:33:16 -05:00
...
}: let
2024-11-21 11:26:08 -05:00
inherit (lib) concatStringsSep getExe removePrefix;
2024-06-27 01:03:50 -04:00
inherit (config.vars) mainUser;
2024-11-21 11:26:08 -05:00
inherit (self.packages.${pkgs.system}) gpu-screen-recorder gsr-kms-server;
2024-06-27 01:03:50 -04:00
hyprPkgs = config.home-manager.users.${mainUser}.wayland.windowManager.hyprland.finalPackage;
2024-11-21 11:26:08 -05:00
cfgDesktop = config.roles.desktop;
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;
};
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;
};
};
home-manager.users.${mainUser} = {
2024-05-05 23:07:06 -04:00
home.packages = [
(pkgs.writeShellApplication {
name = "gpu-save-replay";
2024-11-21 11:26:08 -05:00
runtimeInputs = with pkgs; [procps];
text = ''
pkill --signal SIGUSR1 -f gpu-screen-recorder
'';
})
2024-05-05 23:07:06 -04:00
(pkgs.writeShellApplication {
name = "gsr-start";
2024-11-21 11:26:08 -05:00
runtimeInputs = [
pkgs.pulseaudio
pkgs.xorg.xrandr
gpu-screen-recorder
gsr-kms-server
hyprPkgs
];
text = ''
2024-06-27 01:03:50 -04:00
main="${removePrefix "desc:" cfgDesktop.mainMonitor}"
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 " " [
''-v no''
''-r 1200''
''-df yes''
''-o /home/matt/Videos/Replay''
# Audio settings
''-ac aac''
''-a "$(pactl get-default-sink).monitor"''
''-a "$(pactl get-default-source)"''
# Video settings
''-w "$WINDOW"''
''-f 60''
''-c mkv''
''-k hevc''
''-q very_high''
]}
'';
})
];
wayland.windowManager.hyprland.settings = {
2024-11-12 15:08:13 -05:00
bind = [",F8, exec, ags request 'save-replay'"];
};
};
}