merge dev fork
This commit is contained in:
commit
450117fc3e
5 changed files with 74 additions and 123 deletions
0
displayIcons/MacBook.icns
Normal file → Executable file
0
displayIcons/MacBook.icns
Normal file → Executable file
0
displayIcons/MacBookPro.icns
Normal file → Executable file
0
displayIcons/MacBookPro.icns
Normal file → Executable file
0
displayIcons/ProDisplayXDR.icns
Normal file → Executable file
0
displayIcons/ProDisplayXDR.icns
Normal file → Executable file
0
displayIcons/iMac.icns
Normal file → Executable file
0
displayIcons/iMac.icns
Normal file → Executable file
197
hidpi.sh
197
hidpi.sh
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
sipChecker=($(csrutil status | awk '{ print $5 }'))
|
sipChecker=($(csrutil status | awk '{ print $5 }'))
|
||||||
systemVersion=($(sw_vers -productVersion | cut -d "." -f 2))
|
systemVersion=($(sw_vers -productVersion | cut -d "." -f 2))
|
||||||
|
@ -28,10 +28,12 @@ langEnableOp2="(2) Enable HIDPI (with EDID)"
|
||||||
langEnableOp3="(3) Disable HIDPI"
|
langEnableOp3="(3) Disable HIDPI"
|
||||||
|
|
||||||
langChooseRes="resolution config"
|
langChooseRes="resolution config"
|
||||||
langChooseResOp1="(1) 1080P Display"
|
langChooseResOp1="(1) 1920x1080 Display"
|
||||||
langChooseResOp2="(2) 1080P Display (use 1424x802, fix underscaled after sleep)"
|
langChooseResOp2="(2) 1920x1080 Display (use 1424x802, fix underscaled after sleep)"
|
||||||
langChooseResOp3="(3) 2K Display"
|
langChooseResOp3="(3) 1920x1200 Display"
|
||||||
langChooseResOp4="(4) Manual input resolution"
|
langChooseResOp4="(4) 2560x1440 Display"
|
||||||
|
langChooseResOp5="(5) 3000x2000 Display"
|
||||||
|
langChooseResOpCustom="(6) Manual input resolution"
|
||||||
|
|
||||||
if [[ "${systemLanguage}" == "zh_CN" ]]; then
|
if [[ "${systemLanguage}" == "zh_CN" ]]; then
|
||||||
disableSIP="需要关闭 SIP"
|
disableSIP="需要关闭 SIP"
|
||||||
|
@ -58,10 +60,12 @@ if [[ "${systemLanguage}" == "zh_CN" ]]; then
|
||||||
langEnableOp3="(3) 关闭HIDPI"
|
langEnableOp3="(3) 关闭HIDPI"
|
||||||
|
|
||||||
langChooseRes="选择分辨率配置"
|
langChooseRes="选择分辨率配置"
|
||||||
langChooseResOp1="(1) 1080P 显示屏"
|
langChooseResOp1="(1) 1920x1080 显示屏"
|
||||||
langChooseResOp2="(2) 1080P 显示屏 (使用 1424x802 分辨率,修复睡眠唤醒后的屏幕缩小问题)"
|
langChooseResOp2="(2) 1920x1080 显示屏 (使用 1424x802 分辨率,修复睡眠唤醒后的屏幕缩小问题)"
|
||||||
langChooseResOp3="(3) 2K 显示屏"
|
langChooseResOp3="(3) 1920x1200 显示屏"
|
||||||
langChooseResOp4="(4) 手动输入分辨率"
|
langChooseResOp4="(4) 2560x1440 显示屏"
|
||||||
|
langChooseResOp5="(5) 3000x2000 显示屏"
|
||||||
|
langChooseResOpCustom="(6) 手动输入分辨率"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
downloadHost="https://raw.githubusercontent.com/xzhih/one-key-hidpi/master"
|
downloadHost="https://raw.githubusercontent.com/xzhih/one-key-hidpi/master"
|
||||||
|
@ -99,13 +103,13 @@ function get_edid()
|
||||||
let index++
|
let index++
|
||||||
MonitorName=("$(echo ${display:190:24} | xxd -p -r)")
|
MonitorName=("$(echo ${display:190:24} | xxd -p -r)")
|
||||||
VendorID=${display:16:4}
|
VendorID=${display:16:4}
|
||||||
ProductID=${display:20:4}
|
ProductID=${gMonitor:22:2}${gMonitor:20:2}
|
||||||
|
|
||||||
if [[ $VendorID == 0610 ]]; then
|
if [[ ${VendorID} == 0610 ]]; then
|
||||||
MonitorName="Apple Display"
|
MonitorName="Apple Display"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $VendorID == 1e6d ]]; then
|
if [[ ${VendorID} == 1e6d ]]; then
|
||||||
MonitorName="LG Display"
|
MonitorName="LG Display"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -137,38 +141,11 @@ function get_edid()
|
||||||
gMonitor=${gDisplayInf}
|
gMonitor=${gDisplayInf}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${gMonitor:16:1} == 0 ]]; then
|
EDID=${gMonitor}
|
||||||
# get rid of the prefix 0
|
VendorID=$((0x${gMonitor:16:4}))
|
||||||
gDisplayVendorID_RAW=${gMonitor:17:3}
|
ProductID=$((0x${gMonitor:22:2}${gMonitor:20:2}))
|
||||||
else
|
Vid=($(printf '%x\n' ${VendorID}))
|
||||||
gDisplayVendorID_RAW=${gMonitor:16:4}
|
Pid=($(printf '%x\n' ${ProductID}))
|
||||||
fi
|
|
||||||
|
|
||||||
# convert from hex to dec
|
|
||||||
gDisplayVendorID=$((0x$gDisplayVendorID_RAW))
|
|
||||||
gDisplayProductID_RAW=${gMonitor:20:4}
|
|
||||||
|
|
||||||
# Exchange two bytes
|
|
||||||
# Fix an issue that will cause wrong name of DisplayProductID
|
|
||||||
|
|
||||||
if [[ ${gDisplayProductID_RAW:2:1} == 0 ]]; then
|
|
||||||
# get rid of the prefix 0
|
|
||||||
gDisplayProduct_pr=${gDisplayProductID_RAW:3:1}
|
|
||||||
else
|
|
||||||
gDisplayProduct_pr=${gDisplayProductID_RAW:2:2}
|
|
||||||
fi
|
|
||||||
gDisplayProduct_st=${gDisplayProductID_RAW:0:2}
|
|
||||||
gDisplayProductID_reverse="${gDisplayProduct_pr}${gDisplayProduct_st}"
|
|
||||||
if [[ ${gDisplayProduct_pr} == 0 ]]; then
|
|
||||||
gDisplayProductID_reverse="${gDisplayProduct_st}"
|
|
||||||
fi
|
|
||||||
gDisplayProductID=$((0x$gDisplayProduct_pr$gDisplayProduct_st))
|
|
||||||
|
|
||||||
EDID=$gMonitor
|
|
||||||
VendorID=$gDisplayVendorID
|
|
||||||
ProductID=$gDisplayProductID
|
|
||||||
Vid=$gDisplayVendorID_RAW
|
|
||||||
Pid=$gDisplayProductID_reverse
|
|
||||||
# echo ${Vid}
|
# echo ${Vid}
|
||||||
# echo ${Pid}
|
# echo ${Pid}
|
||||||
# echo $EDID
|
# echo $EDID
|
||||||
|
@ -211,9 +188,7 @@ EEF
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f ${thatDir}/HIDPI/disable ]]; then
|
generate_restore_cmd
|
||||||
generate_restore_cmd
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -225,61 +200,34 @@ mkdir -p ${thisDir}/tmp/
|
||||||
cat > "${thisDir}/tmp/disable" <<-\CCC
|
cat > "${thisDir}/tmp/disable" <<-\CCC
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
systemVersion=($(sw_vers -productVersion | cut -d "." -f 2))
|
|
||||||
|
|
||||||
if [[ "${systemVersion}" -ge "15" ]]; then
|
|
||||||
sudo mount -uw / && killall Finder
|
|
||||||
fi
|
|
||||||
|
|
||||||
function get_edid()
|
function get_edid()
|
||||||
{
|
{
|
||||||
local index=0
|
local index=0
|
||||||
local selection=0
|
local selection=0
|
||||||
|
|
||||||
gDisplayInf=($(ioreg -lw0 | grep -i "IODisplayEDID" | sed -e "/[^<]*</s///" -e "s/\>//"))
|
gDisplayInf=($(ioreg -lw0 | grep -i "IODisplayEDID" | sed -e "/[^<]*</s///" -e "s/\>//"))
|
||||||
|
|
||||||
if [[ "${#gDisplayInf[@]}" -ge 2 ]]; then
|
if [[ "${#gDisplayInf[@]}" -ge 2 ]]; then
|
||||||
|
echo ' Monitors '
|
||||||
# Multi monitors detected. Choose target monitor.
|
echo '------------------------------------'
|
||||||
echo ''
|
echo ' Index | VendorID | ProductID '
|
||||||
echo ' Monitors '
|
echo '------------------------------------'
|
||||||
echo '----------------------------------------------------'
|
|
||||||
echo ' Index | VendorID | ProductID | MonitorName '
|
|
||||||
echo '----------------------------------------------------'
|
|
||||||
|
|
||||||
for display in "${gDisplayInf[@]}"
|
for display in "${gDisplayInf[@]}"
|
||||||
do
|
do
|
||||||
let index++
|
let index++
|
||||||
MonitorName=("$(echo ${display:190:24} | xxd -p -r)")
|
printf " %d | ${display:16:4} | ${gMonitor:22:2}${gMonitor:20:2}\n" $index
|
||||||
VendorID=${display:16:4}
|
|
||||||
ProductID=${display:20:4}
|
|
||||||
|
|
||||||
if [[ $VendorID == 0610 ]]; then
|
|
||||||
MonitorName="Apple Display"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $VendorID == 1e6d ]]; then
|
|
||||||
MonitorName="LG Display"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf " %d | $VendorID | $ProductID | $MonitorName\n" $index
|
|
||||||
done
|
done
|
||||||
|
echo '------------------------------------'
|
||||||
echo '----------------------------------------------------'
|
|
||||||
|
|
||||||
read -p "Choose the display: " selection
|
read -p "Choose the display: " selection
|
||||||
case $selection in
|
case $selection in
|
||||||
[[:digit:]]* )
|
[[:digit:]]* )
|
||||||
if ((selection < 1 || selection > index)); then
|
if ((selection < 1 || selection > index)); then
|
||||||
echo "Enter error. bye";
|
echo "Enter error, bye";
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
let selection-=1
|
let selection-=1
|
||||||
gMonitor=${gDisplayInf[$selection]}
|
gMonitor=${gDisplayInf[$selection]}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
* )
|
||||||
echo "Enter error. bye";
|
echo "Enter error, bye";
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -287,42 +235,22 @@ function get_edid()
|
||||||
gMonitor=${gDisplayInf}
|
gMonitor=${gDisplayInf}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${gMonitor:16:1} == 0 ]]; then
|
|
||||||
gDisplayVendorID_RAW=${gMonitor:17:3}
|
|
||||||
else
|
|
||||||
gDisplayVendorID_RAW=${gMonitor:16:4}
|
|
||||||
fi
|
|
||||||
|
|
||||||
gDisplayVendorID=$((0x$gDisplayVendorID_RAW))
|
|
||||||
gDisplayProductID_RAW=${gMonitor:20:4}
|
|
||||||
|
|
||||||
if [[ ${gDisplayProductID_RAW:2:1} == 0 ]]; then
|
|
||||||
gDisplayProduct_pr=${gDisplayProductID_RAW:3:1}
|
|
||||||
else
|
|
||||||
gDisplayProduct_pr=${gDisplayProductID_RAW:2:2}
|
|
||||||
fi
|
|
||||||
|
|
||||||
gDisplayProduct_st=${gDisplayProductID_RAW:0:2}
|
|
||||||
gDisplayProductID_reverse="${gDisplayProduct_pr}${gDisplayProduct_st}"
|
|
||||||
gDisplayProductID=$((0x$gDisplayProduct_pr$gDisplayProduct_st))
|
|
||||||
|
|
||||||
EDID=$gMonitor
|
EDID=$gMonitor
|
||||||
Vid=$gDisplayVendorID_RAW
|
VendorID=$((0x${gMonitor:16:4}))
|
||||||
Pid=$gDisplayProductID_reverse
|
ProductID=$((0x${gMonitor:22:2}${gMonitor:20:2}))
|
||||||
# echo ${Vid}
|
Vid=($(printf '%x\n' ${VendorID}))
|
||||||
# echo ${Pid}
|
Pid=($(printf '%x\n' ${ProductID}))
|
||||||
# echo $EDID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_edid
|
get_edid
|
||||||
|
|
||||||
if [[ -d ../DisplayVendorID-${Vid} ]]; then
|
if [[ -d ../DisplayVendorID-${Vid} ]]; then
|
||||||
sudo rm -rf ../DisplayVendorID-${Vid}
|
rm -rf ../DisplayVendorID-${Vid}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo rm -rf ../Icons.plist
|
rm -rf ../Icons.plist
|
||||||
sudo cp -r ./backup/* ../
|
cp -r ./backup/* ../
|
||||||
sudo rm -rf ./disable
|
rm -rf ./disable
|
||||||
echo "HIDPI Disabled"
|
echo "HIDPI Disabled"
|
||||||
CCC
|
CCC
|
||||||
|
|
||||||
|
@ -433,27 +361,49 @@ echo ${langChooseResOp1}
|
||||||
echo ${langChooseResOp2}
|
echo ${langChooseResOp2}
|
||||||
echo ${langChooseResOp3}
|
echo ${langChooseResOp3}
|
||||||
echo ${langChooseResOp4}
|
echo ${langChooseResOp4}
|
||||||
|
echo ${langChooseResOp5}
|
||||||
|
echo ${langChooseResOpCustom}
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
#
|
#
|
||||||
read -p "${langInputChoice}: " res
|
read -p "${langInputChoice}: " res
|
||||||
case ${res} in
|
case ${res} in
|
||||||
1 ) create_res_1 1680x944 1440x810 1280x720 1024x576
|
1 ) create_res_1 1680x945 1440x810 1280x720 1024x576
|
||||||
|
create_res_2 1280x800 1280x720 960x600 960x540 640x360
|
||||||
|
create_res_3 840x472 800x450 720x405 640x360 576x324 512x288 420x234 400x225 320x180
|
||||||
|
create_res_4 1680x945 1440x810 1280x720 1024x576 960x540 840x472 800x450 640x360
|
||||||
;;
|
;;
|
||||||
2 ) create_res_1 1680x944 1424x802 1280x720 1024x576
|
2 ) create_res_1 1680x945 1424x802 1280x720 1024x576
|
||||||
|
create_res_2 1280x800 1280x720 960x600 960x540 640x360
|
||||||
|
create_res_3 840x472 800x450 720x405 640x360 576x324 512x288 420x234 400x225 320x180
|
||||||
|
create_res_4 1680x945 1440x810 1280x720 1024x576 960x540 840x472 800x450 640x360
|
||||||
;;
|
;;
|
||||||
3 ) create_res_1 2048x1152 1920x1080 1680x944 1440x810 1280x720
|
3 ) create_res_1 1680x1050 1440x900 1280x800 1024x640
|
||||||
create_res_2 1024x576
|
create_res_2 1280x800 1280x720 960x600 960x540 640x360
|
||||||
create_res_3 960x540
|
create_res_3 840x472 800x450 720x405 640x360 576x324 512x288 420x234 400x225 320x180
|
||||||
create_res_4 2048x1152 1920x1080
|
create_res_4 1680x1050 1440x900 1280x800 1024x640 960x540 840x472 800x450 640x360
|
||||||
|
;;
|
||||||
|
4 ) create_res_1 2560x1440 2048x1152 1920x1080 1760x990 1680x945 1440x810 1360x765 1280x720
|
||||||
|
create_res_2 1360x765 1280x800 1280x720 1024x576 960x600 960x540 640x360
|
||||||
|
create_res_3 960x540 840x472 800x450 720x405 640x360 576x324 512x288 420x234 400x225 320x180
|
||||||
|
create_res_4 2048x1152 1920x1080 1680x945 1440x810 1280x720 1024x576 960x540 840x472 800x450 640x360
|
||||||
|
;;
|
||||||
|
5 ) create_res_1 3000x2000 2880x1920 2250x1500 1920x1280 1680x1050 1440x900 1280x800 1024x640
|
||||||
|
create_res_2 1280x800 1280x720 960x600 960x540 640x360
|
||||||
|
create_res_3 840x472 800x450 720x405 640x360 576x324 512x288 420x234 400x225 320x180
|
||||||
|
create_res_4 1920x1280 1680x1050 1440x900 1280x800 1024x640 960x540 840x472 800x450 640x360
|
||||||
|
;;
|
||||||
|
6 ) custom_res
|
||||||
|
create_res_2 1360x765 1280x800 1280x720 960x600 960x540 640x360
|
||||||
|
create_res_3 840x472 800x450 720x405 640x360 576x324 512x288 420x234 400x225 320x180
|
||||||
|
create_res_4 1680x945 1440x810 1280x720 1024x576 960x540 840x472 800x450 640x360
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "${langEnterError}";
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
4 ) custom_res;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
create_res_2 1280x800 1280x720 960x600 960x540 640x360
|
|
||||||
create_res_3 840x472 800x450 720x405 640x360 576x324 512x288 420x234 400x225 320x180
|
|
||||||
create_res_4 1680x944 1440x810 1280x720 1024x576 960x540 840x472 800x450 640x360
|
|
||||||
|
|
||||||
cat >> "${dpiFile}" <<-\FFF
|
cat >> "${dpiFile}" <<-\FFF
|
||||||
</array>
|
</array>
|
||||||
<key>target-default-ppmm</key>
|
<key>target-default-ppmm</key>
|
||||||
|
@ -474,6 +424,7 @@ function end()
|
||||||
sudo chmod 0644 ${thisDir}/tmp/DisplayVendorID-${Vid}/*
|
sudo chmod 0644 ${thisDir}/tmp/DisplayVendorID-${Vid}/*
|
||||||
sudo cp -r ${thisDir}/tmp/* ${thatDir}/
|
sudo cp -r ${thisDir}/tmp/* ${thatDir}/
|
||||||
sudo rm -rf ${thisDir}/tmp
|
sudo rm -rf ${thisDir}/tmp
|
||||||
|
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES
|
||||||
echo "${langEnabled}"
|
echo "${langEnabled}"
|
||||||
echo "${langEnabledLog}"
|
echo "${langEnabledLog}"
|
||||||
}
|
}
|
||||||
|
@ -572,8 +523,8 @@ function enable_hidpi_with_patch()
|
||||||
version=${EDID:38:2}
|
version=${EDID:38:2}
|
||||||
basicparams=${EDID:40:2}
|
basicparams=${EDID:40:2}
|
||||||
checksum=${EDID:254:2}
|
checksum=${EDID:254:2}
|
||||||
newchecksum=$(printf '%x' $((0x$checksum + 0x$version +0x$basicparams - 0x04 - 0x90)) | tail -c 2)
|
newchecksum=$(printf '%x' $((0x${checksum} + 0x${version} +0x${basicparams} - 0x04 - 0x90)) | tail -c 2)
|
||||||
newedid=${EDID:0:38}0490${EDID:42:212}${newchecksum}
|
newedid=${EDID:0:38}0490${EDID:42:6}e6${EDID:50:204}${newchecksum}
|
||||||
EDid=$(printf ${newedid} | xxd -r -p | base64)
|
EDid=$(printf ${newedid} | xxd -r -p | base64)
|
||||||
|
|
||||||
/usr/bin/sed -i "" "s:EDid:${EDid}:g" ${dpiFile}
|
/usr/bin/sed -i "" "s:EDid:${EDid}:g" ${dpiFile}
|
||||||
|
|
Loading…
Reference in a new issue