Files
neoromantique-dotfiles/home/dot_local/bin/executable_hypr-debounce
David Aizenberg 85a18a0091 sync
2026-02-13 02:21:10 +01:00

25 lines
436 B
Bash

#!/usr/bin/env bash
set -euo pipefail
ms=${1:-200}
shift || true
if [ "$#" -eq 0 ]; then
echo "usage: hypr-debounce <ms> <command...>" >&2
exit 2
fi
key=$(printf '%s\0' "$@" | sha1sum | awk '{print $1}')
state="/tmp/hypr-debounce-$key"
now=$(date +%s%3N)
if [ -f "$state" ]; then
last=$(cat "$state" 2>/dev/null || echo 0)
if [ $((now - last)) -lt "$ms" ]; then
exit 0
fi
fi
printf '%s\n' "$now" > "$state"
exec "$@"