refactor(recording): inline executable helpers
This commit is contained in:
@@ -6,14 +6,6 @@
|
|||||||
}:
|
}:
|
||||||
# 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
|
||||||
slurp = lib.getExe pkgs.slurp;
|
|
||||||
wf-recorder = lib.getExe pkgs.wf-recorder;
|
|
||||||
notify-send = lib.getExe' pkgs.libnotify "notify-send";
|
|
||||||
pgrep = lib.getExe' pkgs.procps "pgrep";
|
|
||||||
pkill = lib.getExe' pkgs.procps "pkill";
|
|
||||||
date = lib.getExe' pkgs.coreutils "date";
|
|
||||||
mkdir = lib.getExe' pkgs.coreutils "mkdir";
|
|
||||||
xdgUserDir = lib.getExe' pkgs.xdg-user-dirs "xdg-user-dir";
|
|
||||||
|
|
||||||
glyph = code: builtins.fromJSON ''"\u${code}"'';
|
glyph = code: builtins.fromJSON ''"\u${code}"'';
|
||||||
|
|
||||||
@@ -24,25 +16,25 @@ let
|
|||||||
# reports it saved.
|
# reports it saved.
|
||||||
# No -a means no audio is captured.
|
# No -a means no audio is captured.
|
||||||
toggle = pkgs.writeShellScript "screen-record-toggle" ''
|
toggle = pkgs.writeShellScript "screen-record-toggle" ''
|
||||||
if ${pgrep} -x wf-recorder >/dev/null; then
|
if ${lib.getExe' pkgs.procps "pgrep"} -x wf-recorder >/dev/null; then
|
||||||
${pkill} -INT -x wf-recorder
|
${lib.getExe' pkgs.procps "pkill"} -INT -x wf-recorder
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
region=$(${slurp}) || exit 0
|
region=$(${lib.getExe pkgs.slurp}) || exit 0
|
||||||
dir="$(${xdgUserDir} VIDEOS)/Recordings"
|
dir="$(${lib.getExe' pkgs.xdg-user-dirs "xdg-user-dir"} VIDEOS)/Recordings"
|
||||||
${mkdir} -p "$dir"
|
${lib.getExe' pkgs.coreutils "mkdir"} -p "$dir"
|
||||||
file="$dir/recording-$(${date} +%Y%m%d-%H%M%S).mp4"
|
file="$dir/recording-$(${lib.getExe' pkgs.coreutils "date"} +%Y%m%d-%H%M%S).mp4"
|
||||||
|
|
||||||
${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."
|
||||||
${wf-recorder} -g "$region" -f "$file"
|
${lib.getExe pkgs.wf-recorder} -g "$region" -f "$file"
|
||||||
${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.
|
# 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 idle, so it shows nothing until then.
|
||||||
recordingStatus = pkgs.writeShellScript "waybar-recording-status" ''
|
recordingStatus = pkgs.writeShellScript "waybar-recording-status" ''
|
||||||
if ${pgrep} -x wf-recorder >/dev/null; then
|
if ${lib.getExe' pkgs.procps "pgrep"} -x wf-recorder >/dev/null; then
|
||||||
printf '{"text":"${glyph "f03d"}","tooltip":"Recording","class":"recording"}\n'
|
printf '{"text":"${glyph "f03d"}","tooltip":"Recording","class":"recording"}\n'
|
||||||
else
|
else
|
||||||
printf '{"text":"","class":"idle"}\n'
|
printf '{"text":"","class":"idle"}\n'
|
||||||
|
|||||||
Reference in New Issue
Block a user