mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
Add 1.25 as a scaling option too and rewrite the matching
This commit is contained in:
@@ -8,24 +8,28 @@ WIDTH=$(echo "$MONITOR_INFO" | jq -r '.width')
|
||||
HEIGHT=$(echo "$MONITOR_INFO" | jq -r '.height')
|
||||
REFRESH_RATE=$(echo "$MONITOR_INFO" | jq -r '.refreshRate')
|
||||
|
||||
# Cycle through scales: 1 → 1.6 → 2 → 3 → 1 (or reverse with --reverse)
|
||||
CURRENT_INT=$(awk -v s="$CURRENT_SCALE" 'BEGIN { printf "%.0f", s * 10 }')
|
||||
# Cycle through scales: 1 → 1.25 → 1.6 → 2 → 3 → 1 (or reverse with --reverse)
|
||||
SCALES=(1 1.25 1.6 2 3)
|
||||
|
||||
# Find the index of the scale closest to the current one (Hyprland may
|
||||
# snap fractional scales to nearby values, so we can't match exactly)
|
||||
CURRENT_IDX=$(awk -v s="$CURRENT_SCALE" -v list="${SCALES[*]}" 'BEGIN {
|
||||
n = split(list, arr, " ")
|
||||
best = 0; best_diff = 1e9
|
||||
for (i = 1; i <= n; i++) {
|
||||
d = s - arr[i]; if (d < 0) d = -d
|
||||
if (d < best_diff) { best_diff = d; best = i - 1 }
|
||||
}
|
||||
print best
|
||||
}')
|
||||
|
||||
if [[ "$1" == "--reverse" ]]; then
|
||||
case "$CURRENT_INT" in
|
||||
10) NEW_SCALE=3 ;;
|
||||
16) NEW_SCALE=1 ;;
|
||||
20) NEW_SCALE=1.6 ;;
|
||||
*) NEW_SCALE=2 ;;
|
||||
esac
|
||||
NEW_IDX=$(( (CURRENT_IDX - 1 + ${#SCALES[@]}) % ${#SCALES[@]} ))
|
||||
else
|
||||
case "$CURRENT_INT" in
|
||||
10) NEW_SCALE=1.6 ;;
|
||||
16) NEW_SCALE=2 ;;
|
||||
20) NEW_SCALE=3 ;;
|
||||
*) NEW_SCALE=1 ;;
|
||||
esac
|
||||
NEW_IDX=$(( (CURRENT_IDX + 1) % ${#SCALES[@]} ))
|
||||
fi
|
||||
|
||||
NEW_SCALE=${SCALES[$NEW_IDX]}
|
||||
|
||||
hyprctl keyword monitor "$ACTIVE_MONITOR,${WIDTH}x${HEIGHT}@${REFRESH_RATE},auto,$NEW_SCALE"
|
||||
notify-send -u low " Display scaling set to ${NEW_SCALE}x"
|
||||
|
||||
Reference in New Issue
Block a user