···142142143143# Tools
144144bind=CTRL,PRINT,exec,grimblast copy area; notify-desktop "copied screenshot of selection to the clipboard"
145145-bind=ALT,PRINT,exec,grimblast copy active; notify-desktop "copied screenshot of active window to clipboard"
146145bind=,PRINT,exec,grimblast copy output; notify-desktop "copied screenshot of screen to the clipboard"
146146+bind=CTRL,XF86AudioMedia,exec,~/.config/hypr/hyprrec.sh
147147+bind=,XF86AudioMedia,exec,~/.config/hypr/hyprrec.sh fullscreen
148148+147149148150bind=CTRL + SHIFT, PRINT, exec, START_TIME=$(date +%s); bash ~/.config/hypr/prettify-ss.sh; notify-desktop "Prettified Screenshot" "Taking $(($(date +%s) - START_TIME))s"
149151
+78
home-manager/dots/hyprrec.sh
···11+## Requirements:
22+## - `slurp`: to select an area
33+## - `notify-send`: to show notifications (provided by libnotify)
44+## - `wl-screenrec`: for screen recording
55+## - `ffmpeg`: for thumbnail generation
66+# If wl-screenrec is already running, stop recording.
77+if pgrep -x "wl-screenrec" > /dev/null; then
88+ killall -s 2 wl-screenrec
99+ exit 0
1010+fi
1111+1212+# Set up file path for recording
1313+FILE="$HOME/Downloads/screencast_$(date +%Y%m%d_%H%M%S).mp4"
1414+1515+# Get audio device information using wireplumber
1616+MONITOR_DEVICE=""
1717+DEFAULT_DEVICE=$(wpctl status | grep "Default Configured Devices" -A 2 | grep "Audio/Sink" | awk '{print $NF}')
1818+1919+if [ -n "$DEFAULT_DEVICE" ]; then
2020+ # Try to construct the monitor device name
2121+ MONITOR_DEVICE="${DEFAULT_DEVICE}.monitor"
2222+2323+ # Check if the device exists by attempting to get its properties
2424+ wpctl inspect $(wpctl status | grep -A 1 "Built-in Audio Analog Stereo" | grep -o '[0-9]\+\.' | head -1 | tr -d '.') > /dev/null 2>&1
2525+ if [ $? -eq 0 ]; then
2626+ echo "Found audio device, will use monitor: $MONITOR_DEVICE"
2727+ AUDIO_ARGS="--audio --audio-device \"$MONITOR_DEVICE\""
2828+ else
2929+ echo "Couldn't confirm monitor device, falling back to default audio"
3030+ AUDIO_ARGS="--audio"
3131+ fi
3232+else
3333+ echo "No default audio device found, falling back to default audio capture"
3434+ AUDIO_ARGS="--audio"
3535+fi
3636+3737+# Process arguments to determine if full screen or area selection
3838+if [ "$1" = "fullscreen" ]; then
3939+ # Full screen recording
4040+ notify-send -t 1000 -a "wl-screenrec" "Starting full screen recording"
4141+ ARGS=""
4242+else
4343+ # Area selection
4444+ notify-send -t 1000 -a "wl-screenrec" "Select area or window to record"
4545+ # Get list of visible windows for slurp to highlight
4646+ WINDOWS="$(hyprctl clients -j | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')"
4747+ # Use slurp with window detection
4848+ GEOMETRY=$(echo "$WINDOWS" | slurp)
4949+ # Check if user canceled selection
5050+ if [ -z "$GEOMETRY" ]; then
5151+ notify-send -t 3000 -a "wl-screenrec" "Recording canceled"
5252+ exit 1
5353+ fi
5454+ notify-send -t 1000 -a "wl-screenrec" "Starting area recording"
5555+ ARGS="-g \"$GEOMETRY\""
5656+fi
5757+5858+# Start recording with the selected parameters
5959+touch /tmp/notify_result.txt
6060+eval "wl-screenrec $ARGS $AUDIO_ARGS -f \"$FILE\"" && \
6161+# Create a thumbnail from the recording
6262+ffmpeg -i "$FILE" -ss 00:00:00 -vframes 1 -update 1 -frames:v 1 /tmp/screenrec_thumbnail.png -y && \
6363+# Notify that recording is saved with clickable action
6464+notify-send -a "wl-screenrec" "Recording saved to $FILE" \
6565+ -i "/tmp/screenrec_thumbnail.png" \
6666+ -A "default=Open" > /tmp/notify_result.txt
6767+6868+# Check if notification was clicked
6969+if [ -f /tmp/notify_result.txt ] && grep -q "default" /tmp/notify_result.txt; then
7070+ if command -v xdg-open > /dev/null; then
7171+ xdg-open "$FILE"
7272+ elif command -v gdbus > /dev/null; then
7373+ gdbus call --session \
7474+ --dest org.freedesktop.FileManager1 \
7575+ --object-path /org/freedesktop/FileManager1 \
7676+ --method org.freedesktop.FileManager1.ShowItems "['file://$FILE']" ""
7777+ fi
7878+fi