Publish tool cleanup and Framework monitoring refinements
This commit is contained in:
@@ -70,7 +70,7 @@ local function movement_exceeded_from(state, contact, origin_x, origin_y,
|
||||
|
||||
local dx = axis_distance(contact.x - origin_x, state.x_absinfo)
|
||||
local dy = axis_distance(contact.y - origin_y, state.y_absinfo)
|
||||
return math.sqrt(dx * dx + dy * dy) > limit_mm
|
||||
return dx * dx + dy * dy > limit_mm * limit_mm
|
||||
end
|
||||
|
||||
local function movement_exceeded(state, contact, limit_mm)
|
||||
|
||||
@@ -32,6 +32,31 @@ grep -q 'minimum_tap_ms = 15' "$override"
|
||||
grep -q 'maximum_tap_ms = 225' "$override"
|
||||
grep -q 'output_event = "KEY_F13"' "$override"
|
||||
|
||||
# Decimal input must neither be parsed as octal nor overflow Bash arithmetic.
|
||||
TOUCHPAD_HOLD_TAP_TEST_ROOT=$test_root bash "$configurator" set --minimum-tap-ms 008
|
||||
grep -qx 'MINIMUM_TAP_MS=8' "$config"
|
||||
before_config=$(sha256sum "$config")
|
||||
before_override=$(sha256sum "$override")
|
||||
for invalid in 2001 18446744073709551616 -1 nope; do
|
||||
if TOUCHPAD_HOLD_TAP_TEST_ROOT=$test_root bash "$configurator" set --minimum-tap-ms "$invalid"; then
|
||||
exit 1
|
||||
fi
|
||||
[[ $(sha256sum "$config") == "$before_config" ]]
|
||||
[[ $(sha256sum "$override") == "$before_override" ]]
|
||||
done
|
||||
|
||||
# Invalid template leaves both installed files unchanged and no staging clutter.
|
||||
printf '%s\n' 'invalid template' > "$test_root/usr/lib64/libinput/plugins/90-touchpad-hold-tap.lua"
|
||||
if TOUCHPAD_HOLD_TAP_TEST_ROOT=$test_root bash "$configurator" set --minimum-pause-ms 150; then
|
||||
exit 1
|
||||
fi
|
||||
[[ $(sha256sum "$config") == "$before_config" ]]
|
||||
[[ $(sha256sum "$override") == "$before_override" ]]
|
||||
[[ $(find "$test_root/etc" -type f | wc -l) == 2 ]]
|
||||
|
||||
printf 'MINIMUM_TAP_MS=12' > "$config"
|
||||
TOUCHPAD_HOLD_TAP_TEST_ROOT=$test_root bash "$configurator" show | grep -qx 'MINIMUM_TAP_MS=12'
|
||||
|
||||
TOUCHPAD_HOLD_TAP_TEST_ROOT=$test_root bash "$configurator" reset
|
||||
[[ ! -e $config ]]
|
||||
[[ ! -e $override ]]
|
||||
|
||||
@@ -17,6 +17,9 @@ minimum_pause_ms=100
|
||||
minimum_tap_ms=10
|
||||
maximum_tap_ms=150
|
||||
output_event=BTN_MIDDLE
|
||||
temporary_config=
|
||||
temporary_override=
|
||||
trap '[[ -z $temporary_config ]] || rm -f -- "$temporary_config"; [[ -z $temporary_override ]] || rm -f -- "$temporary_override"' EXIT
|
||||
|
||||
die()
|
||||
{
|
||||
@@ -33,13 +36,13 @@ require_root()
|
||||
|
||||
validate()
|
||||
{
|
||||
[[ $minimum_anchor_age_ms =~ ^[0-9]+$ ]] || die "minimum anchor age must be an integer"
|
||||
[[ $minimum_pause_ms =~ ^[0-9]+$ ]] || die "minimum pause must be an integer"
|
||||
[[ $minimum_tap_ms =~ ^[0-9]+$ ]] || die "minimum tap duration must be an integer"
|
||||
[[ $maximum_tap_ms =~ ^[0-9]+$ ]] || die "maximum tap duration must be an integer"
|
||||
(( minimum_anchor_age_ms <= 2000 )) || die "minimum anchor age must not exceed 2000 ms"
|
||||
(( minimum_pause_ms <= 2000 )) || die "minimum pause must not exceed 2000 ms"
|
||||
(( maximum_tap_ms >= 1 && minimum_tap_ms <= maximum_tap_ms && maximum_tap_ms <= 2000 )) || \
|
||||
local name
|
||||
for name in minimum_anchor_age_ms minimum_pause_ms minimum_tap_ms maximum_tap_ms; do
|
||||
[[ ${!name} =~ ^0*([0-9]{1,4})$ ]] || die "${name//_/ } must be an integer between 0 and 2000"
|
||||
printf -v "$name" '%d' "$((10#${BASH_REMATCH[1]}))"
|
||||
(( ${!name} <= 2000 )) || die "${name//_/ } must not exceed 2000 ms"
|
||||
done
|
||||
(( maximum_tap_ms >= 1 && minimum_tap_ms <= maximum_tap_ms )) || \
|
||||
die "tap durations must be between 0 and 2000 ms, with a positive maximum and minimum not exceeding maximum"
|
||||
[[ $output_event =~ ^(BTN|KEY)_[A-Z0-9_]+$ ]] || \
|
||||
die "output event must be an evdev BTN_* or KEY_* name"
|
||||
@@ -51,7 +54,7 @@ read_config()
|
||||
return 0
|
||||
fi
|
||||
|
||||
while IFS='=' read -r key value; do
|
||||
while IFS='=' read -r key value || [[ -n $key ]]; do
|
||||
case $key in
|
||||
MINIMUM_ANCHOR_AGE_MS) minimum_anchor_age_ms=$value ;;
|
||||
MINIMUM_PAUSE_MS) minimum_pause_ms=$value ;;
|
||||
@@ -65,27 +68,26 @@ read_config()
|
||||
validate
|
||||
}
|
||||
|
||||
print_config()
|
||||
{
|
||||
printf 'MINIMUM_ANCHOR_AGE_MS=%s\nMINIMUM_PAUSE_MS=%s\nMINIMUM_TAP_MS=%s\nMAXIMUM_TAP_MS=%s\nOUTPUT_EVENT=%s\n' \
|
||||
"$minimum_anchor_age_ms" "$minimum_pause_ms" "$minimum_tap_ms" "$maximum_tap_ms" \
|
||||
"$output_event"
|
||||
}
|
||||
|
||||
write_config()
|
||||
{
|
||||
mkdir -p "$(dirname -- "$config_file")"
|
||||
local temporary
|
||||
temporary=$(mktemp "${config_file}.XXXXXX")
|
||||
trap 'rm -f -- "$temporary"' RETURN
|
||||
printf 'MINIMUM_ANCHOR_AGE_MS=%s\nMINIMUM_PAUSE_MS=%s\nMINIMUM_TAP_MS=%s\nMAXIMUM_TAP_MS=%s\nOUTPUT_EVENT=%s\n' \
|
||||
"$minimum_anchor_age_ms" "$minimum_pause_ms" "$minimum_tap_ms" "$maximum_tap_ms" \
|
||||
"$output_event" > "$temporary"
|
||||
chmod 0644 "$temporary"
|
||||
mv -f -- "$temporary" "$config_file"
|
||||
trap - RETURN
|
||||
temporary_config=$(mktemp "${config_file}.XXXXXX")
|
||||
print_config > "$temporary_config"
|
||||
chmod 0644 "$temporary_config"
|
||||
}
|
||||
|
||||
write_override()
|
||||
{
|
||||
[[ -r $template_file ]] || die "installed plugin was not found"
|
||||
mkdir -p "$(dirname -- "$override_file")"
|
||||
local temporary
|
||||
temporary=$(mktemp "${override_file}.XXXXXX")
|
||||
trap 'rm -f -- "$temporary"' RETURN
|
||||
temporary_override=$(mktemp "${override_file}.XXXXXX")
|
||||
awk -v age="$minimum_anchor_age_ms" -v pause="$minimum_pause_ms" \
|
||||
-v mintap="$minimum_tap_ms" \
|
||||
-v maxtap="$maximum_tap_ms" \
|
||||
@@ -103,10 +105,8 @@ write_override()
|
||||
}
|
||||
{ print }
|
||||
END { if (!replaced) exit 1 }
|
||||
' "$template_file" > "$temporary" || die "installed plugin has an unsupported format"
|
||||
chmod 0644 "$temporary"
|
||||
mv -f -- "$temporary" "$override_file"
|
||||
trap - RETURN
|
||||
' "$template_file" > "$temporary_override" || die "installed plugin has an unsupported format"
|
||||
chmod 0644 "$temporary_override"
|
||||
}
|
||||
|
||||
usage()
|
||||
@@ -125,9 +125,7 @@ case $command in
|
||||
show)
|
||||
[[ $# -eq 1 ]] || die "show takes no arguments"
|
||||
read_config
|
||||
printf 'MINIMUM_ANCHOR_AGE_MS=%s\nMINIMUM_PAUSE_MS=%s\nMINIMUM_TAP_MS=%s\nMAXIMUM_TAP_MS=%s\nOUTPUT_EVENT=%s\n' \
|
||||
"$minimum_anchor_age_ms" "$minimum_pause_ms" "$minimum_tap_ms" "$maximum_tap_ms" \
|
||||
"$output_event"
|
||||
print_config
|
||||
;;
|
||||
set)
|
||||
shift
|
||||
@@ -166,6 +164,9 @@ case $command in
|
||||
validate
|
||||
write_config
|
||||
write_override
|
||||
# Stage both files before replacing either: a bad template must not save settings.
|
||||
mv -f -- "$temporary_config" "$config_file"
|
||||
mv -f -- "$temporary_override" "$override_file"
|
||||
;;
|
||||
reset)
|
||||
[[ $# -eq 1 ]] || die "reset takes no arguments"
|
||||
@@ -178,6 +179,7 @@ case $command in
|
||||
if [[ -e $config_file ]]; then
|
||||
read_config
|
||||
write_override
|
||||
mv -f -- "$temporary_override" "$override_file"
|
||||
else
|
||||
rm -f -- "$override_file"
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: touchpad-hold-tap
|
||||
Version: 0.1.0
|
||||
Release: 10%{?dist}
|
||||
Release: 11%{?dist}
|
||||
Summary: Hold-tap middle-click gesture for touchpads
|
||||
|
||||
License: MIT
|
||||
@@ -57,6 +57,10 @@ if [ "$1" -eq 0 ]; then
|
||||
fi
|
||||
|
||||
%changelog
|
||||
* Sat Sep 12 2026 fedora-tools contributors - 0.1.0-11
|
||||
- Validate timing integers and stage configuration before replacing files
|
||||
- Reduce movement calculation overhead and expand regression tests
|
||||
|
||||
* Sat Sep 05 2026 fedora-tools contributors - 0.1.0-10
|
||||
- Reset stale touch contacts after an interrupted input stream
|
||||
|
||||
|
||||
Reference in New Issue
Block a user