#!/bin/bash # xrandr2 # # prints out the xrandr size number that is equal to or smaller than/closest to # the specified (desired) X and Y screen resolution. # # example: xrandr -s $(xrandr2 1152 864) set -eu X=$1 Y=$2 xrandr | awk " /^[ \*][0-9]/ { if (\$2 <= $X && \$4 <= $Y) { print \$1 exit } } " | tr -c -d '[0-9]'