diff --git a/options/custom/scripts/zoom.sh b/options/custom/scripts/zoom.sh index 97ae79f..ebce925 100644 --- a/options/custom/scripts/zoom.sh +++ b/options/custom/scripts/zoom.sh @@ -4,19 +4,25 @@ # # https://github.com/sigoden/argc -# @arg factor=1 Absolute or relative factor to zoom to, empty to reset +# @arg factor=1.0 Absolute or relative factor to zoom to, empty to reset eval "$(argc --argc-eval "$0" "$@")" factor="$(hyprctl -j getoption cursor:zoom_factor | jq -r .float)" # Current factor -if [[ "${argc_factor:-}" =~ ^[+|-][1-9]\.*[0-9]*$ ]]; then +# Match regex for zero-padded decimals +if [[ "${argc_factor:-}" =~ ^[+|-][0-9]\.[0-9]+$ ]]; then factor="$(bc <<< "$factor ${argc_factor}")" -elif [[ "${argc_factor:-}" =~ ^[1-9]\.*[0-9]*$ ]]; then +elif [[ "${argc_factor:-}" =~ ^[0-9]\.[0-9]+$ ]]; then factor="${argc_factor:-}" else - echo "Factor must be an absolute or relative decimal between 1 and 9" + echo "Factor must be an absolute or relative decimal between 1.0 and 9.9" exit 1 fi +# Reset if outside range +if (("$(bc <<< "$factor < 1")")); then + factor=1.0 +fi + hyprctl keyword cursor:zoom_factor "$factor"