Xrandr script with adjustable scaling for mixing regular and 4k Retina type hidpi monitors

Created Monday 08 June 2015

This might be useful to you if you're using Linux and have a regular monitor and a super hi-def 4k type screen as well; mostly the difficulty might come with scaling, and more fundamentally, dealing with math stuff in bash. Here's my solution, which works for a "regular" monitor on the left and the high dpi one on the right. There's some obvious error checking in here, YMMV.


offsetfloat=`echo "$scale * 1680" | bc`
echo "offsetfloat is $offsetfloat"

offset=$(printf "%.*f\n" 0 $offsetfloat) 
echo "offset is $offset"

xrandr --output HDMI1 --off --output DP1 --mode 1680x1050 --pos 0x0 --rotate normal --scale ${scale}x${scale} --output eDP1 --mode 3200x1800 --pos ${offset}x0 --rotate normal --output VIRTUAL1 --off

Backlinks: Tech Guides