feat(wm): implement declarative screen recording and screenshot suite
- Add `record.sh`, a stateful recording utility using `wf-recorder` and `slurp`, supporting area, window, output, and full-screen captures. - Integrate `grimblast` into the binding layer for high-fidelity screenshots. - Declaratively mount recording scripts and update Hyprland keybindings via `binds-user.lua`. - Remap clipboard manager toggle to `SUPER + C` to accommodate the new video recording shortcut suite. - Provision `grimblast`, `obs-studio`, and `wf-recorder` via host-specific home packages.
This commit is contained in:
1 parent
d5b81699c0
commit
ac0e2784df
3 files changed
+116
No files matched your search
@@ -1 +1,16 @@
|
||||
-- Optional per-user keybind overrides (managed by DMS). Loaded after default binds.
|
||||
|
||||
-- Screen screenshots
|
||||
hl.bind("SUPER + S", hl.dsp.exec_cmd("grimblast --notify copysave area"))
|
||||
hl.bind("SUPER + SHIFT + S", hl.dsp.exec_cmd("grimblast --notify copysave active"))
|
||||
hl.bind("SUPER + CTRL + S", hl.dsp.exec_cmd("grimblast --notify copysave output"))
|
||||
hl.bind("SUPER + SHIFT + CTRL + S", hl.dsp.exec_cmd("grimblast --notify copysave screen"))
|
||||
|
||||
-- Screen video recordings
|
||||
hl.bind("SUPER + V", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh area"))
|
||||
hl.bind("SUPER + SHIFT + V", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh window"))
|
||||
hl.bind("SUPER + CTRL + V", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh output"))
|
||||
hl.bind("SUPER + SHIFT + CTRL + V", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh screen"))
|
||||
|
||||
-- Rebind clipboard manager toggle since SUPER + V is now used for video recording area
|
||||
hl.bind("SUPER + C", hl.dsp.exec_cmd("dms ipc call clipboard toggle"))
|
||||
Executable
+93
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Screen Recording script for Hyprland using wf-recorder
|
||||
# Usage: record.sh [area|window|output|screen]
|
||||
|
||||
PID_FILE="/tmp/wf-recorder.pid"
|
||||
TYPE_FILE="/tmp/wf-recorder.type"
|
||||
OUTPUT_DIR="$HOME/Videos"
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
stop_recording() {
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
kill -INT "$PID"
|
||||
# Wait a moment for wf-recorder to finish writing the file
|
||||
sleep 0.5
|
||||
fi
|
||||
rm -f "$PID_FILE"
|
||||
fi
|
||||
|
||||
# Also double check in case of orphaned wf-recorder instances
|
||||
if pgrep -x "wf-recorder" > /dev/null; then
|
||||
pkill -INT -x wf-recorder
|
||||
sleep 0.5
|
||||
fi
|
||||
|
||||
TYPE="Recording"
|
||||
if [ -f "$TYPE_FILE" ]; then
|
||||
TYPE=$(cat "$TYPE_FILE")
|
||||
rm -f "$TYPE_FILE"
|
||||
fi
|
||||
|
||||
notify-send -t 3000 -u normal "Screen Recorder" "$TYPE stopped and saved to $OUTPUT_DIR"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# If already running, stop recording (no matter what arguments are passed)
|
||||
if pgrep -x "wf-recorder" > /dev/null; then
|
||||
stop_recording
|
||||
fi
|
||||
|
||||
# Determine type
|
||||
MODE="${1:-area}"
|
||||
FILENAME="recording_$(date +%Y-%m-%d_%H-%M-%S).mp4"
|
||||
FILEPATH="$OUTPUT_DIR/$FILENAME"
|
||||
|
||||
GEOM=""
|
||||
TYPE_DESC="Screen Recording"
|
||||
|
||||
case "$MODE" in
|
||||
area)
|
||||
# Select area using slurp
|
||||
GEOM=$(slurp)
|
||||
if [ -z "$GEOM" ]; then
|
||||
notify-send -t 2000 "Screen Recorder" "Recording cancelled"
|
||||
exit 1
|
||||
fi
|
||||
TYPE_DESC="Area Recording"
|
||||
;;
|
||||
window)
|
||||
# Get active window geometry
|
||||
GEOM=$(hyprctl activewindow -j | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')
|
||||
if [ -z "$GEOM" ] || [ "$GEOM" = "null,null nullxnull" ]; then
|
||||
notify-send -t 2000 "Screen Recorder" "No active window found"
|
||||
exit 1
|
||||
fi
|
||||
TYPE_DESC="Window Recording"
|
||||
;;
|
||||
output)
|
||||
# Get focused monitor geometry
|
||||
GEOM=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true) | "\(.x),\(.y) \(.width)x\(.height)"')
|
||||
TYPE_DESC="Monitor Recording"
|
||||
;;
|
||||
screen)
|
||||
# All outputs (no geometry restriction)
|
||||
GEOM=""
|
||||
TYPE_DESC="Full Screen Recording"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Start recording
|
||||
notify-send -t 2000 -u low "Screen Recorder" "Starting $TYPE_DESC..."
|
||||
|
||||
if [ -n "$GEOM" ]; then
|
||||
wf-recorder -g "$GEOM" -f "$FILEPATH" &
|
||||
else
|
||||
wf-recorder -f "$FILEPATH" &
|
||||
fi
|
||||
|
||||
PID=$!
|
||||
echo "$PID" > "$PID_FILE"
|
||||
echo "$TYPE_DESC" > "$TYPE_FILE"
|
||||
@@ -4,7 +4,15 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Host-specific package installations for desktop (Hyprland environment only)
|
||||
home.packages = with pkgs; [
|
||||
grimblast # Screenshot utility for Hyprland
|
||||
obs-studio # High-feature video capture and streaming studio
|
||||
wf-recorder # Light recorder for Wayland-based window managers
|
||||
];
|
||||
|
||||
# Mount custom Hyprland and DankMaterialShell configuration files declaratively
|
||||
home.file.".config/hypr/hyprland.lua".source = ./config/hypr/hyprland.lua;
|
||||
home.file.".config/hypr/dms".source = ./config/hypr/dms;
|
||||
home.file.".config/hypr/scripts".source = ./config/hypr/scripts;
|
||||
}
|
||||
Reference in new issue
Block a user