Make it possible to travel backwards on the resolution scaling

This commit is contained in:
David Heinemeier Hansson
2026-04-22 16:15:30 +02:00
parent fc258fa8b2
commit 0d5b680c2a
2 changed files with 17 additions and 7 deletions
+16 -7
View File
@@ -8,15 +8,24 @@ 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
# 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 }')
case "$CURRENT_INT" in
10) NEW_SCALE=1.6 ;;
16) NEW_SCALE=2 ;;
20) NEW_SCALE=3 ;;
*) NEW_SCALE=1 ;;
esac
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
else
case "$CURRENT_INT" in
10) NEW_SCALE=1.6 ;;
16) NEW_SCALE=2 ;;
20) NEW_SCALE=3 ;;
*) NEW_SCALE=1 ;;
esac
fi
hyprctl keyword monitor "$ACTIVE_MONITOR,${WIDTH}x${HEIGHT}@${REFRESH_RATE},auto,$NEW_SCALE"
notify-send -u low "󰍹 Display scaling set to ${NEW_SCALE}x"