refactor(gsr): improve startup script and dynamically set monitor
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-02-16 16:41:10 -05:00
parent 5d20dacdf9
commit 662809f7ac
2 changed files with 49 additions and 42 deletions

View file

@ -1,11 +1,3 @@
# Autostart programs
exec-once = sleep 10; tmux new-session -s gsr -d 'bash -c $HOME/.config/gsr.sh'
# TODO: add gpu-save-replay bind
## fix fullscreen game resolution
exec-once = xrandr --output DP-5 --primary
# Cosmetic # Cosmetic
general { general {
gaps_in = 10 gaps_in = 10

View file

@ -5,7 +5,9 @@
gpu-screen-recorder-src, gpu-screen-recorder-src,
... ...
}: let }: let
inherit (config.vars) mainUser; inherit (config.vars) mainUser mainMonitor;
inherit (lib) concatStringsSep removePrefix;
hyprPkgs = config.home-manager.users.${mainUser}.wayland.windowManager.hyprland.finalPackage;
# TODO: manage this with ags # TODO: manage this with ags
gsr = pkgs.stdenv.mkDerivation { gsr = pkgs.stdenv.mkDerivation {
@ -48,16 +50,6 @@
''; '';
}; };
in { in {
environment.systemPackages = with pkgs; [
pulseaudio # for getting audio sink
gsr
# TODO: add notif on success
(writeShellScriptBin "gpu-save-replay" ''
exec ${pkgs.procps}/bin/pkill --signal SIGUSR1 -f gpu-screen-recorder
'')
];
# Allow CUDA on boot # Allow CUDA on boot
boot.kernelModules = ["nvidia-uvm"]; boot.kernelModules = ["nvidia-uvm"];
@ -78,31 +70,54 @@ in {
}; };
home-manager.users.${mainUser} = { home-manager.users.${mainUser} = {
wayland.windowManager.hyprland.settings.bind = [ home.packages = with pkgs; [
", F8, exec, gpu-save-replay" gsr
];
# TODO: add mic sound
xdg.configFile."gsr.sh" = {
executable = true;
text =
/*
bash
*/
''
export WINDOW=DP-5
export CONTAINER=mkv
export QUALITY=very_high
export CODEC=auto
export AUDIO_CODEC=aac
export FRAMERATE=60
export REPLAYDURATION=1200
export OUTPUTDIR=/home/matt/Videos/Replay
export MAKEFOLDERS=yes
# export ADDITIONAL_ARGS=
# Disable compositor in X11 for best performance (writeShellApplication {
exec /bin/sh -c 'AUDIO="''${AUDIO_DEVICE:-$(pactl get-default-sink).monitor}"; gpu-screen-recorder -v no -w $WINDOW -c $CONTAINER -q $QUALITY -k $CODEC -ac $AUDIO_CODEC -a "$(pactl get-default-source)" -a "$AUDIO" -f $FRAMERATE -r $REPLAYDURATION -o "$OUTPUTDIR" -mf $MAKEFOLDERS $ADDITIONAL_ARGS' name = "gpu-save-replay";
runtimeInputs = [procps];
text = ''
# TODO: add notif on success
pkill --signal SIGUSR1 -f gpu-screen-recorder
''; '';
})
(writeShellApplication {
name = "gsr-start";
runtimeInputs = [pulseaudio hyprPkgs xorg.xrandr];
text = ''
main="${removePrefix "desc:" 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''
''-mf 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 = {
bind = [",F8, exec, gpu-save-replay"];
exec-once = [
"sleep 10; tmux new-session -s gsr -d gsr-start"
];
}; };
}; };
} }