Since you're working with multiple monitors, I have a script I've been fiddling with for a while now, and it may be of benefit to you since you are having issues with your monitor setup.
The script does nothing <TO> your system, it just examines your available display setup and provides a pile of useful info about your whole setup and how all the monitors and their geometry is laid out, taking scaling into account as well.
I've used this script with a 2 monitor display 43" centered above a 17" laptop display
and on my other setup with 2 x 24" displays side by side and centrally located above a 15" laptop
In my case, the 43" display has xrandr scaling if 1.75, and both the 24' displays are scaled to 1.25
In both cases, the laptops are set to 200% using the mint display utility.
Anyway, give it a try and see if you find it useful.
Code: Select all
#!/bin/bash
##########
#
# Project :
# Started :
# Author : Terry Dwyer
# Module :
# Description :
#
# If scaling is to be used, the legal values will be
# 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75 and 3
# Other values are likely to cause blurring of the display
# I have a 4k 43" monitor and use a scaling factor of 1.75
# and my son who has excellent vision tells me there is
# no blurring evident
#
# <<< Try using this >>>
# xrandr --listactivemonitors | grep DP-1
# 0: +*eDP-1-1 1920/344x1080/194+989+1080 eDP-1-1
# 1: +DP-1-2-1 1920/521x1080/293+0+0 DP-1-2-1
# 2: +DP-1-2-2 1920/521x1080/293+1920+0 DP-1-2-2
#
##########
# start of code here
# Get The caracteristics for the overall screen display (All monitors combined)
Screen=`xrandr | grep Screen | awk '{print $1, $2, $7, $8, $9, $10}' | sed s/,//`
# Declare the array to hold the info for each f the connected monitors
declare -a PortArray
# Get a list of connected monitors into a temp file
xrandr | grep " connected" > mondef.txt
# How many monitors are there
Nummon=`cat mondef.txt | wc -l`
i=1
echo ; echo
#Create an empty array
#PortArray=()
for i in $( seq 1 $((Nummon)) ) ; do
#Primary=""
#Read each line of the temp file with the monitor list
Mon=`awk -v c=$i 'NR==c { print $0 }' mondef.txt`
# Read each monitor definition into the array
# Next, sed strips out the primary and prints the current line "1"
# and the round braces surrounding some of the text in each line
#PortArray[$i]=`echo "${Mon}" | sed -e 's/ primary//1'`
PortArray[$i]=`echo "${Mon}" | sed -e 's/ primary//; s/(//; s/)//1'`
#echo "${PortArray[$i]}"
#echo "------------------------------------"
#echo
done
# This is just to check that each array element is acessible
echo "---------------- 0 ------------------"
echo "Display definition: ${Screen}"
i=1
for i in $( seq 1 $((Nummon)) ) ; do
echo "---------------- $i ------------------"
echo "Monitor $i: ${PortArray[$i]}"
#echo "-------------------------------------"
# Native Res / Monitor res = xrandr scaling factor
# This applies to both horizontal and vertical values
# We can conclude that if $NatRes and $MonRes are not
# the same string value then scaling has been applied
Port=`echo ${PortArray[$i]} | cut -d " " -f 1`
# Pfield tells you if the monitor is set to be primary
# NatRes This is the natural res for the monitor
MonStr=`xrandr | grep "$Port" -A 1`
Pfield=`echo ${MonStr} | cut -d " " -f 3`
if [ ${Pfield} == primary ] ; then
Primary=Yes
NatRes=`echo ${MonStr} | cut -d " " -f 16`
else
Primary=No
NatRes=`echo ${MonStr} | cut -d " " -f 15`
fi
# NatRes=`echo ${PortArray[$i]} | cut -d " " -f 3 | cut -d "+" -f 1`<< Doesnt work
# This is the monitor offset in the definition of screen 0
# Not necessary because $Hoffset and Voffset do the same
# MonOffset=`xrandr | grep "eDP-1-1" | cut -d " " -f 4 | cut -d "+" -f 2,3`
# This is the resolution the monitor is currently set to
MonRes=`echo ${PortArray[$i]} | cut -d " " -f 3 | cut -d "+" -f 1`
# Compare the string values for NatRes and $MonRes
if [ $NatRes != $MonRes ] ; then
Natural=`echo $NatRes | cut -d "x" -f 1`
Scaled=`echo $MonRes | cut -d "x" -f 1`
#echo "MonRes: $MonRes Scaled: $Scaled Natural: $Natural"
#echo " >> Press any key to continue" ; read z
Scale=`printf %.2f "$((10**2 * $Scaled / $Natural))e-2"`
else
Scale="No Scaling"
fi
# This is the Horizontal "X" and Vertical "Y" resolutions of the monitor
MonX=`echo ${MonRes} | cut -d "x" -f 1` # Horiz
MonY=`echo ${MonRes} | cut -d "x" -f 2` # Ver
# Think of the total display areas occupied by all monitors to be
# a rectangle that each monitor covers a non-overlapping part of.
# Horizontal offset is the amount in pixels the monitor is distant from
# the left origin, I.E. the left edge of the total display area
# The Vertical offset is the distance the monitor is fron the top
# edge of the total display area
Hoffset=`echo ${PortArray[$i]} | cut -d " " -f 3 | cut -d "+" -f 2`
Voffset=`echo ${PortArray[$i]} | cut -d " " -f 3 | cut -d "+" -f 3`
#echo "Index $i: $Mon"
echo "=========>>>> Port $i: $Port"
if [ -n ${Primary} ] ; then
echo "========>>>> Primary: ${Primary}"
else
echo "========>>>> Primary: ${Primary}"
fi
echo "=====>>>> Native res: $NatRes"
echo "====>>>> Monitor res: $MonRes"
echo "==>>>> Scaling value: $Scale"
echo "=> Horizontal offset: $Hoffset"
echo "==>> Vertical offset: $Voffset"
# To determine if the two monitors are centered vertically
# Divide $MonRes by 2, for both monitors add $Hoffset to the
# smaller value if the original larger value is the same as
# the other two added values, both monitors are centered vertically
if [ ${Hoffset} -eq 0 ] && [ ${Voffset} -eq 0 ] ; then
echo "*** Monitor on ${Port} is Top left"
MonleftX=${MonX}
MonleftY=${MonY}
fi
if [ ${Hoffset} -eq ${MonX} ] && [ ${Voffset} -eq 0 ]; then
echo "*** Monitor on Port ${Port} is Top right"
MonrightX=${MonX}
MonrightY=${MonY}
fi
if [ ${Voffset} -gt 0 ] && [ ${Hoffset} -gt 0 ] ; then
#More logic goes here for the horizontal placement
echo "*** Monitor on ${Port} is below Top monitor"
fi
echo
done
echo "-------------------------------------"
echo
echo
echo "The array contains ${#PortArray[@]} elements"
echo " >> Press <Enter> key to exit" ; read a ; clear
exit 0
Topleft horiz and Vert offsets will equal zero
Topright horiz will be equal or greater than Horiz width of Topleft. vert offset will be zero
Middle could be in the middle of a horizontal line of the middle could be below both other monitors
This assumes the monitor arrangement are:
----------------------
| TopLeft | TopRight |
----------------------
| Laptop |
----------
exit 0
# EOF