-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
106 lines (105 loc) · 3.58 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{
lib,
config,
username,
...
}:
let
cfg = config.gsr;
in
{
options = {
gsr = {
enable = lib.mkEnableOption "Enable gsr in NixOS";
};
};
config = lib.mkIf cfg.enable {
programs.gpu-screen-recorder = {
enable = true;
};
home-manager.users.${username} =
{ pkgs, config, ... }:
let
outputDir = "${config.home.homeDirectory}/Videos";
in
{
home.packages = with pkgs; [
(writeShellApplication {
name = "gsr-save-replay";
runtimeInputs = [
killall
libnotify
];
text = ''
killall -SIGUSR1 gpu-screen-recorder
notify-send -t 3000 -u low 'GPU Screen Recorder' 'Replay saved to <br /> ${outputDir}' -i com.dec05eba.gpu_screen_recorder -a 'GPU Screen Recorder'
'';
})
(writeShellApplication {
name = "gsr-stop-replay";
runtimeInputs = [
killall
libnotify
];
text = ''
killall -SIGINT gpu-screen-recorder
notify-send -t 3000 -u low 'GPU Screen Recorder' 'Replay stopped' -i com.dec05eba.gpu_screen_recorder -a 'GPU Screen Recorder'
'';
})
];
programs.plasma = {
hotkeys = {
commands = {
"gsr-save-replay" = {
name = "Save GSR Replay";
key = "Meta+Ctrl+|";
command = "gsr-save-replay";
comment = "Save GPU Screen Recorder replay";
};
};
};
};
systemd = {
user = {
services = {
"gpu-screen-recorder" = {
Unit = {
Description = "GPU Screen Recorder Service";
PartOf = [ "pipewire.service" ]; # Restart GSR when Pipewire restarts
};
Service = {
Environment = [
"WINDOW=DP-1" # Primary monitor
"CONTAINER=mp4"
"QUALITY=ultra"
"FRAMERATE=60"
"MODE=cfr"
"CODEC=h264"
"AUDIO_CODEC=opus"
"AUDIO_DEVICE_DEFAUlT=alsa_output.usb-Schiit_Audio_USB_Modi_Device-00.analog-stereo.monitor"
"AUDIO_DEVICE_GAME=Game.monitor"
"AUDIO_DEVICE_MIC=mono-microphone"
"AUDIO_DEVICE_VOIP=VoIP.monitor"
"AUDIO_DEVICE_MUSIC=Music.monitor"
"REPLAYDURATION=900"
"OUTPUTDIR=${outputDir}"
"MAKEFOLDERS=no"
"FPSPPS=no"
];
ExecStartPre = "${pkgs.libnotify}/bin/notify-send -t 3000 -u low 'GPU Screen Recorder' 'Replay started' -i com.dec05eba.gpu_screen_recorder -a 'GPU Screen Recorder'";
ExecStart = "${pkgs.gpu-screen-recorder}/bin/gpu-screen-recorder -w $WINDOW -c $CONTAINER -q $QUALITY -f $FRAMERATE -fm $MODE -k $CODEC -ac $AUDIO_CODEC -r $REPLAYDURATION -v $FPSPPS -mf $MAKEFOLDERS -a $AUDIO_DEVICE_DEFAUlT -a $AUDIO_DEVICE_GAME -a $AUDIO_DEVICE_MIC -a $AUDIO_DEVICE_VOIP -a $AUDIO_DEVICE_MUSIC -o $OUTPUTDIR";
KillSignal = "SIGINT";
Restart = "on-failure";
RestartSec = "5";
Type = "simple";
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
};
};
};
};
};
};
}