mirror of
https://github.com/neoromantique/dotfiles.git
synced 2026-03-13 21:53:20 +03:00
25 lines
436 B
Bash
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 "$@"
|