From 0e335a17917897d6d23b925a66c4ea8a300f37aa Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 22 Apr 2026 16:20:26 +0200 Subject: [PATCH] Add 1.25 as a scaling option too and rewrite the matching --- bin/omarchy-hyprland-monitor-scaling-cycle | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/bin/omarchy-hyprland-monitor-scaling-cycle b/bin/omarchy-hyprland-monitor-scaling-cycle index 77924f76..008dc864 100755 --- a/bin/omarchy-hyprland-monitor-scaling-cycle +++ b/bin/omarchy-hyprland-monitor-scaling-cycle @@ -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"