zoom: fix regex matching
Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
parent
20cd92006e
commit
c697d8dd77
1 changed files with 10 additions and 4 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue