feat(wm): implement dynamic system audio capture for screen recording
- Simplify screen recording modes by removing the "all-creen" capture
- Introduce dynamic audio source resolution using `wpctl` to target the
active Pipewire output monitor
- Refactor keybindings to use `CTRL` as a modifier for system audio
toggle:
- `SUPER + W` series for video-only capture.
- `SUPER + Ctrl + W` series for video capture with system audio
loopback
- Harden the recording script to handle audio device resolution failures
gracefully.
This commit is contained in:
1 parent
ebc0e1eff0
commit
ce5e0359c9
2 files changed
+36
-10
No files matched your search
@@ -8,6 +8,6 @@ hl.bind("SUPER + SHIFT + CTRL + S", hl.dsp.exec_cmd("grimblast --notify copysave
|
|||||||
|
|
||||||
-- Screen video recordings (SUPER + W series)
|
-- Screen video recordings (SUPER + W series)
|
||||||
hl.bind("SUPER + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh area"))
|
hl.bind("SUPER + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh area"))
|
||||||
hl.bind("SUPER + SHIFT + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh window"))
|
hl.bind("SUPER + SHIFT + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh output"))
|
||||||
hl.bind("SUPER + CTRL + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh output"))
|
hl.bind("SUPER + CTRL + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh area audio"))
|
||||||
hl.bind("SUPER + SHIFT + CTRL + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh screen"))
|
hl.bind("SUPER + SHIFT + CTRL + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh output audio"))
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Screen Recording script for Hyprland using wf-recorder
|
# Screen Recording script for Hyprland using wf-recorder
|
||||||
# Usage: record.sh [area|window|output|screen]
|
# Usage: record.sh [area|window|output|screen] [audio]
|
||||||
|
|
||||||
PID_FILE="/tmp/wf-recorder.pid"
|
PID_FILE="/tmp/wf-recorder.pid"
|
||||||
TYPE_FILE="/tmp/wf-recorder.type"
|
TYPE_FILE="/tmp/wf-recorder.type"
|
||||||
@@ -42,12 +42,10 @@ fi
|
|||||||
|
|
||||||
# Determine type
|
# Determine type
|
||||||
MODE="${1:-area}"
|
MODE="${1:-area}"
|
||||||
FILENAME="recording_$(date +%Y-%m-%d_%H-%M-%S).mp4"
|
AUDIO_DEVICE=""
|
||||||
FILEPATH="$OUTPUT_DIR/$FILENAME"
|
|
||||||
|
|
||||||
GEOM=""
|
|
||||||
TYPE_DESC="Screen Recording"
|
TYPE_DESC="Screen Recording"
|
||||||
|
|
||||||
|
# Get recording parameters
|
||||||
case "$MODE" in
|
case "$MODE" in
|
||||||
area)
|
area)
|
||||||
# Select area using slurp
|
# Select area using slurp
|
||||||
@@ -79,13 +77,41 @@ case "$MODE" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# If the second argument is "audio", enable system audio recording
|
||||||
|
if [ "$2" = "audio" ]; then
|
||||||
|
# Dynamically find the default output sink's monitor name from PipeWire/WirePlumber
|
||||||
|
SINK_ID=$(wpctl status | sed -n '/Sinks:/,/Sources:/p' | grep '*' | awk '{print $3}' | tr -d '.')
|
||||||
|
if [ -n "$SINK_ID" ]; then
|
||||||
|
NODE_NAME=$(wpctl inspect "$SINK_ID" | grep 'node.name' | awk -F'"' '{print $2}')
|
||||||
|
if [ -n "$NODE_NAME" ]; then
|
||||||
|
AUDIO_DEVICE="${NODE_NAME}.monitor"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# Fallback to default system source if we couldn't resolve the node name
|
||||||
|
if [ -z "$AUDIO_DEVICE" ]; then
|
||||||
|
AUDIO_DEVICE="default"
|
||||||
|
fi
|
||||||
|
TYPE_DESC="${TYPE_DESC} (with Audio)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
FILENAME="recording_$(date +%Y-%m-%d_%H-%M-%S).mp4"
|
||||||
|
FILEPATH="$OUTPUT_DIR/$FILENAME"
|
||||||
|
|
||||||
# Start recording
|
# Start recording
|
||||||
notify-send -t 2000 -u low "Screen Recorder" "Starting $TYPE_DESC..."
|
notify-send -t 2000 -u low "Screen Recorder" "Starting $TYPE_DESC..."
|
||||||
|
|
||||||
if [ -n "$GEOM" ]; then
|
if [ -n "$AUDIO_DEVICE" ]; then
|
||||||
wf-recorder -g "$GEOM" -f "$FILEPATH" &
|
if [ -n "$GEOM" ]; then
|
||||||
|
wf-recorder -a "$AUDIO_DEVICE" -g "$GEOM" -f "$FILEPATH" &
|
||||||
|
else
|
||||||
|
wf-recorder -a "$AUDIO_DEVICE" -f "$FILEPATH" &
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
|
if [ -n "$GEOM" ]; then
|
||||||
|
wf-recorder -g "$GEOM" -f "$FILEPATH" &
|
||||||
|
else
|
||||||
wf-recorder -f "$FILEPATH" &
|
wf-recorder -f "$FILEPATH" &
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PID=$!
|
PID=$!
|
||||||
|
|||||||
Reference in new issue
Block a user