2024-09-24 16:01:49 +00:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
|
|
|
# @describe Wrapper for zooming display
|
|
|
|
#
|
|
|
|
# https://github.com/sigoden/argc
|
|
|
|
|
2024-09-27 20:11:57 +00:00
|
|
|
# @arg factor=1.0 Absolute or relative factor to zoom to, empty to reset
|
2024-09-24 16:01:49 +00:00
|
|
|
|
|
|
|
eval "$(argc --argc-eval "$0" "$@")"
|
|
|
|
|
|
|
|
factor="$(hyprctl -j getoption cursor:zoom_factor | jq -r .float)" # Current factor
|
|
|
|
|
2024-09-27 20:11:57 +00:00
|
|
|
# Match regex for zero-padded decimals
|
|
|
|
if [[ "${argc_factor:-}" =~ ^[+|-][0-9]\.[0-9]+$ ]]; then
|
2024-09-24 16:01:49 +00:00
|
|
|
factor="$(bc <<< "$factor ${argc_factor}")"
|
2024-09-27 20:11:57 +00:00
|
|
|
elif [[ "${argc_factor:-}" =~ ^[0-9]\.[0-9]+$ ]]; then
|
2024-09-24 16:01:49 +00:00
|
|
|
factor="${argc_factor:-}"
|
|
|
|
else
|
2024-09-27 20:11:57 +00:00
|
|
|
echo "Factor must be an absolute or relative decimal between 1.0 and 9.9"
|
2024-09-24 16:01:49 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-09-27 20:11:57 +00:00
|
|
|
# Reset if outside range
|
|
|
|
if (("$(bc <<< "$factor < 1")")); then
|
|
|
|
factor=1.0
|
|
|
|
fi
|
|
|
|
|
2024-09-24 16:01:49 +00:00
|
|
|
hyprctl keyword cursor:zoom_factor "$factor"
|