From 3f1e34ef95ecebfc086a333d45f84151cf0f6244 Mon Sep 17 00:00:00 2001 From: alexion Date: Sun, 11 Oct 2026 22:37:30 -0400 Subject: [PATCH] refactor(recording): signal status updates --- .../modules/desktop/utilities/recording.nix | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/configs/nixos/modules/desktop/utilities/recording.nix b/configs/nixos/modules/desktop/utilities/recording.nix index 11b5455..5ee2bfc 100644 --- a/configs/nixos/modules/desktop/utilities/recording.nix +++ b/configs/nixos/modules/desktop/utilities/recording.nix @@ -7,13 +7,13 @@ }: # Keybound screen recording: pick a region, then toggle a video-only capture. let - # A single key both starts and stops. - # A running wf-recorder is stopped with SIGINT so it finalises the file. - # Otherwise slurp picks a region and wf-recorder runs in the foreground until - # that stop arrives, so this instance lives for the whole recording and then - # reports it saved. - # No -a means no audio is captured. - toggle = pkgs.writeShellScript "screen-record-toggle" '' + # A single key starts and stops recording. + # Waybar refreshes on state changes instead of polling. + recordingToggle = pkgs.writeShellScript "screen-record-toggle" '' + refresh_waybar() { + ${lib.getExe' pkgs.procps "pkill"} -RTMIN+10 waybar >/dev/null 2>&1 || true + } + if ${lib.getExe' pkgs.procps "pgrep"} -x wf-recorder >/dev/null; then ${lib.getExe' pkgs.procps "pkill"} -INT -x wf-recorder exit 0 @@ -25,12 +25,15 @@ let 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.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" ''; - # Lit while a wf-recorder capture is running. - # Empty text collapses the widget when idle, so it shows nothing until then. + # Empty text collapses the widget when recording is idle. recordingStatus = pkgs.writeShellScript "waybar-recording-status" '' if ${lib.getExe' pkgs.procps "pgrep"} -x wf-recorder >/dev/null; then printf '{"text":"${util.glyph "f03d"}","tooltip":"Recording","class":"recording"}\n' @@ -48,7 +51,7 @@ in keys = "SUPER + SHIFT + R"; action = { kind = "exec"; - command = "${toggle}"; + command = "${recordingToggle}"; }; }; @@ -57,7 +60,8 @@ in settings = { return-type = "json"; exec = "${recordingStatus}"; - interval = 1; + interval = "once"; + signal = 10; }; }; };