diff --git a/hosts/desktop/config/hypr/dms/binds-user.lua b/hosts/desktop/config/hypr/dms/binds-user.lua index c410a95..8c24020 100644 --- a/hosts/desktop/config/hypr/dms/binds-user.lua +++ b/hosts/desktop/config/hypr/dms/binds-user.lua @@ -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")) diff --git a/hosts/desktop/config/hypr/scripts/record.sh b/hosts/desktop/config/hypr/scripts/record.sh new file mode 100755 index 0000000..4a00504 --- /dev/null +++ b/hosts/desktop/config/hypr/scripts/record.sh @@ -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" diff --git a/hosts/desktop/home.nix b/hosts/desktop/home.nix index 8f93c37..1c95e30 100644 --- a/hosts/desktop/home.nix +++ b/hosts/desktop/home.nix @@ -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; }