File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,6 +153,14 @@ min = 5
153153max = 3600
154154visible_when = { key = " replay_enabled" , values = [" true" ] }
155155
156+ [[setting ]]
157+ key = " replay_filename_pattern"
158+ type = " string"
159+ label_key = " settings.replay_filename_pattern.label"
160+ default = " replay_%Y%m%d_%H%M%S"
161+ description_key = " settings.replay_filename_pattern.description"
162+ visible_when = { key = " replay_enabled" , values = [" true" ] }
163+
156164[[setting ]]
157165key = " replay_storage"
158166type = " select"
Original file line number Diff line number Diff line change 360360local function saveReplay ()
361361 if state ~= "replaying" then return end
362362 noctalia .runAsync ("pkill -SIGUSR1 -f 'gpu-screen-recorder.*-r ' 2>/dev/null || true" )
363+
364+ local pattern = cfg ("replay_filename_pattern" )
365+ if pattern ~= nil and pattern ~= "" then
366+ local dir = outputDirectory ()
367+ local targetFile = `{dir }{noctalia .formatTime (pattern )}.mp4`
368+ -- Replay mode only accepts an output directory (-o "{dir}"), so gpu-screen-recorder
369+ -- names the file itself as Replay_<timestamp>.mp4 using its own clock when it
370+ -- finalizes. Rather than predict that name, poll for the newest Replay_*.mp4 the
371+ -- save produced and rename it. `ref` (one second before the SIGUSR1) bounds the
372+ -- search so an earlier replay sitting in the directory is never picked up.
373+ local ref = (tonumber (noctalia .formatTime ("%s" )) or 0 ) - 1
374+ local claim = `f=$(find {shellQuote (dir )} -maxdepth 1 -name 'Replay_*.mp4' -newermt "@{ref }" -printf '%T@ %p\\ n' 2>/dev/null | sort -n | tail -1 | cut -d' ' -f2-); `
375+ .. `if [ -n "$f" ]; then mv -n -- "$f" {shellQuote (targetFile )}; else exit 1; fi`
376+ local attempts = 50
377+ local function poll ()
378+ noctalia .runAsync (`sleep 0.2; {claim }` , function (result )
379+ if result .exitCode == 0 then return end
380+ if attempts > 0 then
381+ attempts -= 1
382+ poll ()
383+ end
384+ end )
385+ end
386+ poll ()
387+ end
388+
363389 noctalia .notify (noctalia .tr ("notify.replay-saved" ))
364390end
365391
Original file line number Diff line number Diff line change 9898 "replay_duration" : {
9999 "label" : " Replay seconds"
100100 },
101+ "replay_filename_pattern" : {
102+ "label" : " Replay filename pattern" ,
103+ "description" : " Date-format pattern for saved replays without extension; use %s for Unix timestamp"
104+ },
101105 "replay_storage" : {
102106 "label" : " Replay storage" ,
103107 "options" : {
Original file line number Diff line number Diff line change 9898 "replay_duration" : {
9999 "label" : " Secondes de relecture"
100100 },
101+ "replay_filename_pattern" : {
102+ "label" : " Modèle de nom de fichier de relecture" ,
103+ "description" : " Modèle de date pour les relectures sauvegardées sans extension; utilisez %s pour l'horodatage Unix"
104+ },
101105 "replay_storage" : {
102106 "label" : " Stockage de relecture" ,
103107 "options" : {
You can’t perform that action at this time.
0 commit comments