Created
August 24, 2025 02:07
-
-
Save thiagopnts/d90e80162e5d61af03ee7db018d82354 to your computer and use it in GitHub Desktop.
bind = $mainMod SHIFT, R, exec, hyprrecord
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| OUTDIR="${HOME}/Videos" | |
| PIDFILE="${XDG_RUNTIME_DIR:-/tmp}/hyprrecord.pid" | |
| notify() { | |
| if command -v notify-send >/dev/null 2>&1; then | |
| notify-send -a "hyprrecord" "$@" | |
| fi | |
| } | |
| is_running() { | |
| [[ -f "$PIDFILE" ]] && ps -p "$(cat "$PIDFILE")" >/dev/null 2>&1 | |
| } | |
| start() { | |
| mkdir -p "$OUTDIR" | |
| FILENAME="${OUTDIR}/$(date +'%Y-%m-%d_%H-%M-%S').mp4" | |
| GEOM="$(slurp || true)" | |
| [[ -z "${GEOM}" ]] && exit 0 | |
| setsid nohup wf-recorder -g "${GEOM}" -f "${FILENAME}" >/dev/null 2>&1 & | |
| echo $! > "$PIDFILE" | |
| notify "Recording started" "→ ${FILENAME}" | |
| } | |
| stop() { | |
| if ! is_running; then | |
| [[ -f "$PIDFILE" ]] && rm -f "$PIDFILE" | |
| exit 0 | |
| fi | |
| PID="$(cat "$PIDFILE")" | |
| kill -INT "$PID" 2>/dev/null || true | |
| for _ in {1..20}; do | |
| sleep 0.1 | |
| ps -p "$PID" >/dev/null 2>&1 || break | |
| done | |
| rm -f "$PIDFILE" | |
| notify "Recording stopped" | |
| } | |
| toggle() { | |
| if is_running; then | |
| stop | |
| else | |
| start | |
| fi | |
| } | |
| cmd="${1:-toggle}" | |
| case "$cmd" in | |
| start|stop|toggle) "$cmd" ;; | |
| *) echo "Usage: hyprrecord [start|stop|toggle]"; exit 2 ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment