#!/bin/env bash # CLI options DMENU_CMD="" while getopts ":d:" opt; do case "$opt" in d) DMENU_CMD="$OPTARG" ;; *) ;; esac done shift $((OPTIND - 1)) if [ -z "$DMENU_CMD" ]; then notify-send "Missing launcher" "Use -d to provide a dmenu command" exit 1 fi read -r -a DMENU_ARR <<< "$DMENU_CMD" DMENU_BIN="${DMENU_ARR[0]}" command -v "$DMENU_BIN" &>/dev/null || { notify-send "Launcher not found" "$DMENU_BIN is not installed"; exit 1; } # Directories SCREENSHOT_DIR="${HOME}/Pictures" RECORDING_DIR="${HOME}/Videos" # Ensure directories exist mkdir -p "$SCREENSHOT_DIR" "$RECORDING_DIR" # Stop active wl-screenrec session if pgrep -u "$USER" wl-screenrec > /dev/null; then pkill -INT -u "$USER" wl-screenrec notify-send "Recording stopped" # Ask if user wants to compress the video COMPRESS=$(printf "%b" "āœ… compress\nāŒ keep original" | "${DMENU_ARR[@]}" "šŸ—œļø Compress video?") if [[ "$COMPRESS" == "āœ… compress" ]]; then # Find the most recent video file LATEST_VIDEO=$(find "$RECORDING_DIR" -name "*.mp4" -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2-) if [[ -n "$LATEST_VIDEO" ]] && [[ -f "$LATEST_VIDEO" ]]; then COMPRESSED_VIDEO="${LATEST_VIDEO%.mp4}_compressed.mp4" notify-send "Compressing video..." "This may take a moment" if ffmpeg -i "$LATEST_VIDEO" -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k "$COMPRESSED_VIDEO" -y &>/dev/null; then notify-send "Compression complete" "$COMPRESSED_VIDEO" # Ask if user wants to delete original DELETE_ORIGINAL=$(printf "%b" "šŸ—‘ļø delete original\nšŸ“ keep both" | "${DMENU_ARR[@]}" "Delete original?") if [[ "$DELETE_ORIGINAL" == "šŸ—‘ļø delete original" ]]; then rm "$LATEST_VIDEO" notify-send "Original deleted" "Keeping compressed version only" fi else notify-send "Compression failed" "Keeping original file" fi fi fi exit 0 fi # Get current outputs dynamically OUTPUTS=$(hyprctl monitors | grep "Monitor" | awk '{print $2}' | paste -sd " " -) OPTIONS=$( cat <