Rewrite services
This commit is contained in:
parent
242afda5b0
commit
98eef0ecda
|
@ -13,11 +13,15 @@ let
|
|||
fi
|
||||
'';
|
||||
|
||||
gsr-start-replay = pkgs.writeShellScriptBin "gsr-start-replay" ''
|
||||
gsr-record = pkgs.writeShellScriptBin "gsr-start-recording" ''
|
||||
systemctl --user start gpu-screen-recorder.service
|
||||
'';
|
||||
|
||||
gsr-replay = pkgs.writeShellScriptBin "gsr-start-replay" ''
|
||||
systemctl --user start gsr-replay.service
|
||||
'';
|
||||
|
||||
gsr-stop-replay = pkgs.writeShellScriptBin "gsr-stop-replay" ''
|
||||
gsr-stop = pkgs.writeShellScriptBin "gsr-stop-replay" ''
|
||||
systemctl --user stop gsr-replay.service
|
||||
'';
|
||||
|
||||
|
@ -26,8 +30,9 @@ in
|
|||
{
|
||||
environment.systemPackages = [
|
||||
gsr-save-replay
|
||||
gsr-start-replay
|
||||
gsr-stop-replay
|
||||
gsr-replay
|
||||
gsr-record
|
||||
gsr-stop
|
||||
];
|
||||
|
||||
security.wrappers."gsr-kms-server" = {
|
||||
|
@ -53,10 +58,10 @@ in
|
|||
extraGSettingsOverridePackages = with pkgs; [ gnome.gnome-settings-daemon ];
|
||||
};
|
||||
|
||||
systemd.user.services."gsr-replay" = {
|
||||
systemd.user.services = rec {
|
||||
"gpu-screen-recorder" = {
|
||||
after = [ "graphical-session.target" ];
|
||||
description = "GPU Screen Recorder replay service";
|
||||
enable = false; # Disabled by default to save resources
|
||||
description = "GPU Screen Recorder service";
|
||||
serviceConfig = {
|
||||
Environment = [
|
||||
"AUDIO_CODEC=opus"
|
||||
|
@ -65,20 +70,33 @@ in
|
|||
"FRAMERATE=60"
|
||||
"MAKEFOLDERS=no"
|
||||
"QUALITY=very_high"
|
||||
"REPLAYDURATION=300"
|
||||
"WINDOW=screen"
|
||||
];
|
||||
ExecStart = pkgs.writeShellScript "start-gpu-screen-recorder-replay" ''
|
||||
${pkgs.gpu-screen-recorder}/bin/gpu-screen-recorder -a "$(${pkgs.pulseaudio}/bin/pactl get-default-sink).monitor" -a "$(${pkgs.pulseaudio}/bin/pactl get-default-source)" -ac "$AUDIO_CODEC" -c "$CONTAINER" -f "$FRAMERATE" -k "$CODEC" -mf "$MAKEFOLDERS" -o "${outputDir}" -q "$QUALITY" -r "$REPLAYDURATION" -v no -w "$WINDOW" $ADDITIONAL_ARGS
|
||||
#${pkgs.killall}/bin/killall gpu-screen-recorder
|
||||
|
||||
if [ -n "$REPLAYDURATION" ]; then
|
||||
REPLAYARG="-r $REPLAYDURATION"
|
||||
else
|
||||
REPLAYARG=""
|
||||
fi
|
||||
|
||||
${pkgs.gpu-screen-recorder}/bin/gpu-screen-recorder $REPLAYARG -a "$(${pkgs.pulseaudio}/bin/pactl get-default-sink).monitor" -a "$(${pkgs.pulseaudio}/bin/pactl get-default-source)" -ac "$AUDIO_CODEC" -c "$CONTAINER" -f "$FRAMERATE" -k "$CODEC" -mf "$MAKEFOLDERS" -o "${outputDir}" -q "$QUALITY" -v no -w "$WINDOW" $ADDITIONAL_ARGS
|
||||
'';
|
||||
Restart = "on-failure";
|
||||
RestartSec = "5s";
|
||||
Type = "simple";
|
||||
};
|
||||
wantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
|
||||
systemd.user.services."gsr-audio-device-changer" = {
|
||||
"gsr-replay" = gpu-screen-recorder // {
|
||||
description = "GPU Screen Recorder replay service";
|
||||
serviceConfig = gpu-screen-recorder.serviceConfig // {
|
||||
Environment = gpu-screen-recorder.serviceConfig.Environment ++ [ "REPLAYDURATION=300" ];
|
||||
};
|
||||
};
|
||||
|
||||
"gsr-replay-change-audio" = {
|
||||
after = [ "gsr-replay.service" ];
|
||||
description = "Restart GPU Screen Recorder replay service on audio device change";
|
||||
requires = [ "gsr-replay.service" ];
|
||||
|
@ -90,10 +108,11 @@ in
|
|||
fi
|
||||
done
|
||||
'';
|
||||
Restart = "always";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "5s";
|
||||
Type = "simple";
|
||||
};
|
||||
wantedBy = [ "gsr-replay.service" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue