我以前在旧款笔记本电脑上使用过 newrez,它一直运行良好。现在我买了一台新电脑,一开始它无法工作,因为它没有检测到 LVDS1 显示器,经过研究后,我发现我有一个 eDP1 显示器,并使用 gedit 将 newrez 文件上的所有 LDVS1 实例替换为 eDP1。这使得缩放工作正常,但鼠标被困在一个与旧分辨率大小相同的不可见区域中。有什么想法吗?
答案1
因此,经过一段时间的自行调查...我找到了答案。如果有人遇到同样的问题,即出现“当前显示器必须是 LVDS1”错误,那么你的笔记本电脑可能配有 eDP1 显示器。如果是这种情况,只需创建一个空文件并将其粘贴到里面即可。这是“newrez”的代码,但我更改了一些内容,使其适用于 eDP1 显示器。如果你有 LVDS1,那么你应该使用原始的 newrez。
以您想要的方式保存文件,我将其保存为 newrez-edp1,然后将其标记为可执行文件。运行它并选择您想要使用的分辨率。
希望这可以为您节省一些调查时间。
#!/bin/bash
# newrez
# Marc Brumlik, Tailored Software Inc, [email protected]
# up to v 0.8
# use 'xrandr' to scale video output to the display
# v 0.9
# Wed Jan 2 05:23:54 CST 2013
# rewrite to handle mouse boundaries when scaled (mouse confined)
# by setting requested resolution to the unused VGA1 device
# then scaling that for display on the LVDS1 device
# v 1.1
# Fri Dec 20 08:28:08 CST 2013
# fixed issue where setting to "default" after some other resulution
# left mouse-area at prior resolution
# v 1.1 for eDP1 Thu Jan 13
# Changed some code for this to be compatible with eDP1
# All credit goes to original creator
umask 000
# resolution can optionally be specified on command line
newrez=$1
# we MUST be running xrandr 1.3 or higher
if xrandr -v | grep "RandR version 1.[012]"
then zenity --info --title="XRandR version is too old" --text="You must be running Xrandr
version 1.3 or newer!
Time to upgrade your system :-)"
exit 0
fi
# find the currently connected devices, make a list
devices=`xrandr -q | grep connected | grep -v disconnected | cut -d"(" -f1`
# there MUST be a "connected" LVDS1 and a "disconnected" VGA1
current=`xrandr -q`
if echo "$current" | grep "eDP1 connected" >/dev/null
then : OK
else zenity --info --title="PROBLEM" --text="Current display must be eDP1"; exit 0
fi
default=`echo "$current" | grep -A 1 "^eDP1" | tail -1 | awk '{print $1}'`
H=`echo $default | cut -d'x' -f1`
V=`echo $default | cut -d'x' -f2`
HZ=`echo $default | awk '{print $2}' | tr -d '[*+]'`
# echo DEFAULT: $default $H $V
if [ -z "$newrez" ]
then while true
do
newrez=`zenity --entry --title="Set New Resolution" \
--text="Default Resolution: $default\n\nNew size (eg 1280x750 or 1450x1000)\n -or- \"default\""` || exit 0
case $newrez in
default|[0-9]*x[0-9]*) break ;;
esac
done
fi
case $newrez in
default) xrandr --output eDP1 --mode $default --scale 1x1 --panning $H"x"$V
xrandr --addmode VGA1 $default
xrandr --newmode $default $newmode
xrandr --output VGA1 --mode $default --scale 1x1 --panning $H"x"$V
exit 0 ;;
esac
newH=`echo $newrez | cut -d'x' -f1`
newV=`echo $newrez | cut -d'x' -f2`
modeline=`cvt $newH $newV $HZ | grep Modeline`
newmode=`echo "$modeline" | sed 's/^.*"//'`
cvtrez=`echo "$modeline" | sed -e 's/_.*//' -e 's/^.*"//'`
if [ "$newrez" != "$cvtrez" ]
then newrez=$cvtrez
newH=`echo $newrez | cut -d'x' -f1`
newV=`echo $newrez | cut -d'x' -f2`
fi
scaleH=`echo -e "scale=10\n$newH / $H\nquit" | bc`
scaleV=`echo -e "scale=10\n$newV / $V\nquit" | bc`
if echo "$current" | grep -A 100 "^VGA1" | grep $newrez >/dev/null
then : already there
else xrandr --newmode "$newrez" $newmode
xrandr --addmode VGA1 $newrez
fi
if xrandr --output VGA1 --mode $newrez --output eDP1 --fb $newrez --scale $scaleH"x"$scaleV --panning $newH"x"$newV 2>&1 | tee -a /tmp/xrandr.err
then : success
else zenity --info --title="Xrandr produced this error" --text="`cat /tmp/xrandr.err`"
The problem could be that Your video driver
does not support xrandr version 1.3
rm -f /tmp/xrandr.err
fi