refactor(recording): signal status updates #174

Merged
alexion merged 1 commits from refactor/recording-module-cleanup into main 2026-10-11 22:38:54 -04:00
Showing only changes of commit 3f1e34ef95 - Show all commits

View File

@@ -7,13 +7,13 @@
}: }:
# Keybound screen recording: pick a region, then toggle a video-only capture. # Keybound screen recording: pick a region, then toggle a video-only capture.
let let
# A single key both starts and stops. # A single key starts and stops recording.
# A running wf-recorder is stopped with SIGINT so it finalises the file. # Waybar refreshes on state changes instead of polling.
# Otherwise slurp picks a region and wf-recorder runs in the foreground until recordingToggle = pkgs.writeShellScript "screen-record-toggle" ''
# that stop arrives, so this instance lives for the whole recording and then refresh_waybar() {
# reports it saved. ${lib.getExe' pkgs.procps "pkill"} -RTMIN+10 waybar >/dev/null 2>&1 || true
# No -a means no audio is captured. }
toggle = pkgs.writeShellScript "screen-record-toggle" ''
if ${lib.getExe' pkgs.procps "pgrep"} -x wf-recorder >/dev/null; then if ${lib.getExe' pkgs.procps "pgrep"} -x wf-recorder >/dev/null; then
${lib.getExe' pkgs.procps "pkill"} -INT -x wf-recorder ${lib.getExe' pkgs.procps "pkill"} -INT -x wf-recorder
exit 0 exit 0
@@ -25,12 +25,15 @@ let
file="$dir/recording-$(${lib.getExe' pkgs.coreutils "date"} +%Y%m%d-%H%M%S).mp4" file="$dir/recording-$(${lib.getExe' pkgs.coreutils "date"} +%Y%m%d-%H%M%S).mp4"
${lib.getExe' pkgs.libnotify "notify-send"} -a "Screen recording" "Recording started" "Region capture, no audio." ${lib.getExe' pkgs.libnotify "notify-send"} -a "Screen recording" "Recording started" "Region capture, no audio."
${lib.getExe pkgs.wf-recorder} -g "$region" -f "$file" ${lib.getExe pkgs.wf-recorder} -g "$region" -f "$file" &
recorder=$!
refresh_waybar
wait "$recorder" || true
refresh_waybar
${lib.getExe' pkgs.libnotify "notify-send"} -a "Screen recording" "Recording saved" "$file" ${lib.getExe' pkgs.libnotify "notify-send"} -a "Screen recording" "Recording saved" "$file"
''; '';
# Lit while a wf-recorder capture is running. # Empty text collapses the widget when recording is idle.
# Empty text collapses the widget when idle, so it shows nothing until then.
recordingStatus = pkgs.writeShellScript "waybar-recording-status" '' recordingStatus = pkgs.writeShellScript "waybar-recording-status" ''
if ${lib.getExe' pkgs.procps "pgrep"} -x wf-recorder >/dev/null; then if ${lib.getExe' pkgs.procps "pgrep"} -x wf-recorder >/dev/null; then
printf '{"text":"${util.glyph "f03d"}","tooltip":"Recording","class":"recording"}\n' printf '{"text":"${util.glyph "f03d"}","tooltip":"Recording","class":"recording"}\n'
@@ -48,7 +51,7 @@ in
keys = "SUPER + SHIFT + R"; keys = "SUPER + SHIFT + R";
action = { action = {
kind = "exec"; kind = "exec";
command = "${toggle}"; command = "${recordingToggle}";
}; };
}; };
@@ -57,7 +60,8 @@ in
settings = { settings = {
return-type = "json"; return-type = "json";
exec = "${recordingStatus}"; exec = "${recordingStatus}";
interval = 1; interval = "once";
signal = 10;
}; };
}; };
}; };