2019-11-18 14:47:08 -06:00
|
|
|
|
#!/bin/bash
|
2019-01-23 12:53:19 -06:00
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
cat <<EEF
|
2020-11-15 05:26:11 -06:00
|
|
|
|
_ _ _____ _____ _____ _____
|
|
|
|
|
| | | | |_ _| | __ \ | __ \ |_ _|
|
|
|
|
|
| |__| | | | | | | | | |__) | | |
|
|
|
|
|
| __ | | | | | | | | ___/ | |
|
|
|
|
|
| | | | _| |_ | |__| | | | _| |_
|
|
|
|
|
|_| |_| |_____| |_____/ |_| |_____|
|
|
|
|
|
|
|
|
|
|
============================================
|
|
|
|
|
EEF
|
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
currentDir="$(cd $(dirname -- $0) && pwd)"
|
2019-07-30 11:23:11 -05:00
|
|
|
|
systemLanguage=($(locale | grep LANG | sed s/'LANG='// | tr -d '"' | cut -d "." -f 1))
|
2022-08-26 04:53:23 -05:00
|
|
|
|
is_applesilicon=$([[ "$(uname -m)" == "arm64" ]] && echo true || echo false)
|
2019-07-30 11:23:11 -05:00
|
|
|
|
|
|
|
|
|
langDisplay="Display"
|
|
|
|
|
langMonitors="Monitors"
|
|
|
|
|
langIndex="Index"
|
|
|
|
|
langVendorID="VendorID"
|
|
|
|
|
langProductID="ProductID"
|
|
|
|
|
langMonitorName="MonitorName"
|
|
|
|
|
langChooseDis="Choose the display"
|
|
|
|
|
langInputChoice="Enter your choice"
|
|
|
|
|
langEnterError="Enter error, bye"
|
|
|
|
|
langBackingUp="Backing up..."
|
|
|
|
|
langEnabled="Enabled, please reboot."
|
|
|
|
|
langDisabled="Disabled, restart takes effect"
|
|
|
|
|
langEnabledLog="Rebooting the logo for the first time will become huge, then it will not be."
|
|
|
|
|
langCustomRes="Enter the HIDPI resolution, separated by a space,like this: 1680x945 1600x900 1440x810"
|
|
|
|
|
|
|
|
|
|
langChooseIcon="Display Icon"
|
|
|
|
|
langNotChange="Do not change"
|
|
|
|
|
|
2022-08-26 04:53:23 -05:00
|
|
|
|
langEnableHIDPI="(%d) Enable HIDPI"
|
|
|
|
|
langEnableHIDPIEDID="(%d) Enable HIDPI (with EDID)"
|
|
|
|
|
langDisableHIDPI="(%d) Disable HIDPI"
|
2019-07-30 11:23:11 -05:00
|
|
|
|
|
2020-07-06 03:56:41 -05:00
|
|
|
|
langDisableOpt1="(1) Disable HIDPI on this monitor"
|
|
|
|
|
langDisableOpt2="(2) Reset all settings to macOS default"
|
|
|
|
|
|
2019-07-30 11:23:11 -05:00
|
|
|
|
langChooseRes="resolution config"
|
2019-08-17 11:44:03 -05:00
|
|
|
|
langChooseResOp1="(1) 1920x1080 Display"
|
|
|
|
|
langChooseResOp2="(2) 1920x1080 Display (use 1424x802, fix underscaled after sleep)"
|
|
|
|
|
langChooseResOp3="(3) 1920x1200 Display"
|
|
|
|
|
langChooseResOp4="(4) 2560x1440 Display"
|
|
|
|
|
langChooseResOp5="(5) 3000x2000 Display"
|
|
|
|
|
langChooseResOpCustom="(6) Manual input resolution"
|
2019-07-30 11:23:11 -05:00
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
if [[ "${systemLanguage}" == "zh_CN" ]]; then
|
2019-07-30 11:23:11 -05:00
|
|
|
|
langDisplay="显示器"
|
|
|
|
|
langMonitors="显示器"
|
|
|
|
|
langIndex="序号"
|
|
|
|
|
langVendorID="供应商ID"
|
|
|
|
|
langProductID="产品ID"
|
|
|
|
|
langMonitorName="显示器名称"
|
|
|
|
|
langChooseDis="选择显示器"
|
|
|
|
|
langInputChoice="输入你的选择"
|
|
|
|
|
langEnterError="输入错误,再见了您嘞!"
|
|
|
|
|
langBackingUp="正在备份(怎么还原请看说明)..."
|
|
|
|
|
langEnabled="开启成功,重启生效"
|
|
|
|
|
langDisabled="关闭成功,重启生效"
|
|
|
|
|
langEnabledLog="首次重启开机logo会变得巨大,之后就不会了"
|
|
|
|
|
langCustomRes="输入想要开启的 HIDPI 分辨率,用空格隔开,就像这样:1680x945 1600x900 1440x810"
|
|
|
|
|
|
|
|
|
|
langChooseIcon="选择显示器ICON"
|
|
|
|
|
langNotChange="保持原样"
|
|
|
|
|
|
2022-08-26 04:53:23 -05:00
|
|
|
|
langEnableHIDPI="(%d) 开启HIDPI"
|
|
|
|
|
langEnableHIDPIEDID="(%d) 开启HIDPI(同时注入EDID)"
|
|
|
|
|
langDisableHIDPI="(%d) 关闭HIDPI"
|
2019-07-30 11:23:11 -05:00
|
|
|
|
|
2020-07-06 03:56:41 -05:00
|
|
|
|
langDisableOpt1="(1) 在此显示器上禁用 HIDPI"
|
|
|
|
|
langDisableOpt2="(2) 还原所有设置至 macOS 默认"
|
|
|
|
|
|
2019-07-30 11:23:11 -05:00
|
|
|
|
langChooseRes="选择分辨率配置"
|
2019-08-17 11:44:03 -05:00
|
|
|
|
langChooseResOp1="(1) 1920x1080 显示屏"
|
|
|
|
|
langChooseResOp2="(2) 1920x1080 显示屏 (使用 1424x802 分辨率,修复睡眠唤醒后的屏幕缩小问题)"
|
|
|
|
|
langChooseResOp3="(3) 1920x1200 显示屏"
|
|
|
|
|
langChooseResOp4="(4) 2560x1440 显示屏"
|
|
|
|
|
langChooseResOp5="(5) 3000x2000 显示屏"
|
|
|
|
|
langChooseResOpCustom="(6) 手动输入分辨率"
|
2019-07-30 11:23:11 -05:00
|
|
|
|
fi
|
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function get_edid() {
|
2018-12-16 22:22:24 -06:00
|
|
|
|
local index=0
|
|
|
|
|
local selection=0
|
|
|
|
|
|
|
|
|
|
gDisplayInf=($(ioreg -lw0 | grep -i "IODisplayEDID" | sed -e "/[^<]*</s///" -e "s/\>//"))
|
|
|
|
|
|
2019-01-23 12:53:19 -06:00
|
|
|
|
if [[ "${#gDisplayInf[@]}" -ge 2 ]]; then
|
|
|
|
|
|
2018-12-16 22:22:24 -06:00
|
|
|
|
# Multi monitors detected. Choose target monitor.
|
2019-07-30 11:23:11 -05:00
|
|
|
|
echo ""
|
|
|
|
|
echo " "${langMonitors}" "
|
|
|
|
|
echo "--------------------------------------------------------"
|
|
|
|
|
echo " "${langIndex}" | "${langVendorID}" | "${langProductID}" | "${langMonitorName}" "
|
|
|
|
|
echo "--------------------------------------------------------"
|
2019-01-23 12:53:19 -06:00
|
|
|
|
|
|
|
|
|
# Show monitors.
|
2020-11-15 18:50:08 -06:00
|
|
|
|
for display in "${gDisplayInf[@]}"; do
|
2019-01-23 12:53:19 -06:00
|
|
|
|
let index++
|
2020-11-15 18:50:08 -06:00
|
|
|
|
MonitorName=("$(echo ${display:190:24} | xxd -p -r)")
|
2019-07-30 11:23:11 -05:00
|
|
|
|
VendorID=${display:16:4}
|
2021-03-02 00:11:59 -06:00
|
|
|
|
ProductID=${display:22:2}${display:20:2}
|
2019-07-30 11:23:11 -05:00
|
|
|
|
|
2019-11-18 14:47:08 -06:00
|
|
|
|
if [[ ${VendorID} == 0610 ]]; then
|
2019-07-30 11:23:11 -05:00
|
|
|
|
MonitorName="Apple Display"
|
|
|
|
|
fi
|
|
|
|
|
|
2019-11-18 14:47:08 -06:00
|
|
|
|
if [[ ${VendorID} == 1e6d ]]; then
|
2019-07-30 11:23:11 -05:00
|
|
|
|
MonitorName="LG Display"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
printf " %d | ${VendorID} | ${ProductID} | ${MonitorName}\n" ${index}
|
2018-12-16 22:22:24 -06:00
|
|
|
|
done
|
2019-01-23 12:53:19 -06:00
|
|
|
|
|
2019-07-30 11:23:11 -05:00
|
|
|
|
echo "--------------------------------------------------------"
|
2019-01-23 12:53:19 -06:00
|
|
|
|
|
2018-12-16 22:22:24 -06:00
|
|
|
|
# Let user make a selection.
|
2019-01-23 12:53:19 -06:00
|
|
|
|
|
2019-07-30 11:23:11 -05:00
|
|
|
|
read -p "${langChooseDis}: " selection
|
2019-01-23 12:53:19 -06:00
|
|
|
|
case $selection in
|
2020-11-15 18:50:08 -06:00
|
|
|
|
[[:digit:]]*)
|
|
|
|
|
# Lower selection (arrays start at zero).
|
|
|
|
|
if ((selection < 1 || selection > index)); then
|
|
|
|
|
echo "${langEnterError}"
|
2020-07-06 03:56:41 -05:00
|
|
|
|
exit 1
|
2020-11-15 18:50:08 -06:00
|
|
|
|
fi
|
|
|
|
|
let selection-=1
|
|
|
|
|
gMonitor=${gDisplayInf[$selection]}
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
echo "${langEnterError}"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
2018-12-16 22:22:24 -06:00
|
|
|
|
esac
|
2019-01-23 12:53:19 -06:00
|
|
|
|
else
|
2018-12-16 22:22:24 -06:00
|
|
|
|
gMonitor=${gDisplayInf}
|
|
|
|
|
fi
|
|
|
|
|
|
2019-11-18 14:47:08 -06:00
|
|
|
|
EDID=${gMonitor}
|
|
|
|
|
VendorID=$((0x${gMonitor:16:4}))
|
|
|
|
|
ProductID=$((0x${gMonitor:22:2}${gMonitor:20:2}))
|
|
|
|
|
Vid=($(printf '%x\n' ${VendorID}))
|
|
|
|
|
Pid=($(printf '%x\n' ${ProductID}))
|
2019-07-30 11:23:11 -05:00
|
|
|
|
# echo ${Vid}
|
|
|
|
|
# echo ${Pid}
|
2018-12-16 22:22:24 -06:00
|
|
|
|
# echo $EDID
|
|
|
|
|
}
|
2020-11-15 18:50:08 -06:00
|
|
|
|
|
2022-08-26 04:53:23 -05:00
|
|
|
|
# For Apple silicon there is no EDID. Get VID/PID in other way
|
|
|
|
|
function get_vidpid_applesilicon() {
|
|
|
|
|
local index=0
|
|
|
|
|
local selection=0
|
|
|
|
|
|
|
|
|
|
# Apple ioreg display class
|
|
|
|
|
local appleDisplClass='AppleCLCD2'
|
|
|
|
|
|
|
|
|
|
# XPath as key.val
|
|
|
|
|
local value="/following-sibling::*[1]"
|
|
|
|
|
local get="/text()"
|
|
|
|
|
|
|
|
|
|
# XPath keys
|
|
|
|
|
local displattr="/key[.='DisplayAttributes']"
|
|
|
|
|
local prodattr="/key[.='ProductAttributes']"
|
|
|
|
|
local vendid="/key[.='LegacyManufacturerID']"
|
|
|
|
|
local prodid="/key[.='ProductID']"
|
|
|
|
|
local prodname="/key[.='ProductName']"
|
|
|
|
|
|
|
|
|
|
# VID/PID/Prodname
|
|
|
|
|
local prodAttrsQuery="/$displattr$value$prodattr$value"
|
|
|
|
|
local vendIDQuery="$prodAttrsQuery$vendid$value$get"
|
|
|
|
|
local prodIDQuery="$prodAttrsQuery$prodid$value$get"
|
|
|
|
|
local prodNameQuery="$prodAttrsQuery$prodname$value$get"
|
|
|
|
|
|
|
|
|
|
# Get VIDs, PIDs, Prodnames
|
|
|
|
|
local vends=($(ioreg -arw0 -d1 -c $appleDisplClass | xpath -q -n -e "$vendIDQuery"))
|
|
|
|
|
local prods=($(ioreg -arw0 -d1 -c $appleDisplClass | xpath -q -n -e "$prodIDQuery"))
|
|
|
|
|
local prodnames=($(ioreg -arw0 -d1 -c $appleDisplClass | xpath -q -n -e "$prodNameQuery"))
|
|
|
|
|
|
|
|
|
|
if [[ "${#prods[@]}" -ge 2 ]]; then
|
|
|
|
|
|
|
|
|
|
# Multi monitors detected. Choose target monitor.
|
|
|
|
|
echo ""
|
|
|
|
|
echo " "${langMonitors}" "
|
|
|
|
|
echo "------------------------------------------------------------"
|
|
|
|
|
echo " "${langIndex}" | "${langVendorID}" | "${langProductID}" | "${langMonitorName}" "
|
|
|
|
|
echo "------------------------------------------------------------"
|
|
|
|
|
|
|
|
|
|
# Show monitors.
|
|
|
|
|
for prod in "${prods[@]}"; do
|
|
|
|
|
MonitorName=${prodnames[$index]}
|
|
|
|
|
VendorID=${vends[$index]}
|
|
|
|
|
ProductID=${prods[$index]}
|
|
|
|
|
|
|
|
|
|
let index++
|
|
|
|
|
|
|
|
|
|
if [[ ${VendorID} == 0610 ]]; then
|
|
|
|
|
MonitorName="Apple Display"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ${VendorID} == 1e6d ]]; then
|
|
|
|
|
MonitorName="LG Display"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
printf " %d | ${VendorID} | ${ProductID} | ${MonitorName}\n" ${index}
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "--------------------------------------------------------"
|
|
|
|
|
|
|
|
|
|
# Let user make a selection.
|
|
|
|
|
|
|
|
|
|
read -p "${langChooseDis}: " selection
|
|
|
|
|
case $selection in
|
|
|
|
|
[[:digit:]]*)
|
|
|
|
|
# Lower selection (arrays start at zero).
|
|
|
|
|
if ((selection < 1 || selection > index)); then
|
|
|
|
|
echo "${langEnterError}"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
let selection-=1
|
|
|
|
|
dispid=$selection
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
echo "${langEnterError}"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
else
|
|
|
|
|
# One monitor detected
|
|
|
|
|
dispid=0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
VendorID=${vends[$dispid]}
|
|
|
|
|
ProductID=${prods[$dispid]}
|
|
|
|
|
Vid=($(printf '%x\n' ${VendorID}))
|
|
|
|
|
Pid=($(printf '%x\n' ${ProductID}))
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-10 11:03:20 -05:00
|
|
|
|
# init
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function init() {
|
|
|
|
|
rm -rf ${currentDir}/tmp/
|
|
|
|
|
mkdir -p ${currentDir}/tmp/
|
|
|
|
|
|
|
|
|
|
libDisplaysDir="/Library/Displays"
|
|
|
|
|
targetDir="${libDisplaysDir}/Contents/Resources/Overrides"
|
|
|
|
|
sysDisplayDir="/System${targetDir}"
|
|
|
|
|
Overrides="\/Library\/Displays\/Contents\/Resources\/Overrides"
|
|
|
|
|
sysOverrides="\/System${Overrides}"
|
|
|
|
|
|
|
|
|
|
if [[ ! -d "${targetDir}" ]]; then
|
|
|
|
|
sudo mkdir -p "${targetDir}"
|
|
|
|
|
fi
|
2020-11-15 05:26:11 -06:00
|
|
|
|
|
|
|
|
|
downloadHost="https://raw.githubusercontent.com/xzhih/one-key-hidpi/master"
|
2020-11-15 18:50:08 -06:00
|
|
|
|
if [ -d "${currentDir}/displayIcons" ]; then
|
2020-11-15 05:26:11 -06:00
|
|
|
|
downloadHost="file://${currentDir}"
|
2018-04-02 13:59:50 -05:00
|
|
|
|
fi
|
2020-07-06 03:56:41 -05:00
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
DICON="com\.apple\.cinema-display"
|
|
|
|
|
imacicon=${sysOverrides}"\/DisplayVendorID\-610\/DisplayProductID\-a032\.tiff"
|
|
|
|
|
mbpicon=${sysOverrides}"\/DisplayVendorID\-610\/DisplayProductID\-a030\-e1e1df\.tiff"
|
|
|
|
|
mbicon=${sysOverrides}"\/DisplayVendorID\-610\/DisplayProductID\-a028\-9d9da0\.tiff"
|
|
|
|
|
lgicon=${sysOverrides}"\/DisplayVendorID\-1e6d\/DisplayProductID\-5b11\.tiff"
|
|
|
|
|
proxdricon=${Overrides}"\/DisplayVendorID\-610\/DisplayProductID\-ae2f\_Landscape\.tiff"
|
|
|
|
|
|
2022-08-26 04:53:23 -05:00
|
|
|
|
if [[ $is_applesilicon == true ]]; then
|
|
|
|
|
get_vidpid_applesilicon
|
|
|
|
|
else
|
|
|
|
|
get_edid
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check if monitor was found
|
|
|
|
|
if [[ -z $VendorID || -z $ProductID || $VendorID == 0 || $ProductID == 0 ]]; then
|
|
|
|
|
echo "No monitors found. Exiting..."
|
|
|
|
|
exit 2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Your monitor VID/PID: $Vid:$Pid"
|
|
|
|
|
|
|
|
|
|
# Finally generate restore command
|
2020-11-15 18:50:08 -06:00
|
|
|
|
generate_restore_cmd
|
2019-01-23 12:53:19 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function generate_restore_cmd() {
|
2019-07-31 08:28:21 -05:00
|
|
|
|
|
2022-08-26 04:53:23 -05:00
|
|
|
|
if [[ $is_applesilicon == true ]]; then
|
|
|
|
|
cat >"$(cd && pwd)/.hidpi-disable" <<-\CCC
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
function get_vidpid_applesilicon() {
|
|
|
|
|
local index=0
|
|
|
|
|
local selection=0
|
|
|
|
|
|
|
|
|
|
# Apple ioreg display class
|
|
|
|
|
local appleDisplClass='AppleCLCD2'
|
|
|
|
|
|
|
|
|
|
# XPath as key.val
|
|
|
|
|
local value="/following-sibling::*[1]"
|
|
|
|
|
local get="/text()"
|
|
|
|
|
|
|
|
|
|
# XPath keys
|
|
|
|
|
local displattr="/key[.='DisplayAttributes']"
|
|
|
|
|
local prodattr="/key[.='ProductAttributes']"
|
|
|
|
|
local vendid="/key[.='LegacyManufacturerID']"
|
|
|
|
|
local prodid="/key[.='ProductID']"
|
|
|
|
|
local prodname="/key[.='ProductName']"
|
|
|
|
|
|
|
|
|
|
# VID/PID/Prodname
|
|
|
|
|
local prodAttrsQuery="/$displattr$value$prodattr$value"
|
|
|
|
|
local vendIDQuery="$prodAttrsQuery$vendid$value$get"
|
|
|
|
|
local prodIDQuery="$prodAttrsQuery$prodid$value$get"
|
|
|
|
|
local prodNameQuery="$prodAttrsQuery$prodname$value$get"
|
|
|
|
|
|
|
|
|
|
# Get VIDs, PIDs, Prodnames
|
|
|
|
|
local vends=($(ioreg -arw0 -d1 -c $appleDisplClass | xpath -q -n -e "$vendIDQuery"))
|
|
|
|
|
local prods=($(ioreg -arw0 -d1 -c $appleDisplClass | xpath -q -n -e "$prodIDQuery"))
|
|
|
|
|
local prodnames=($(ioreg -arw0 -d1 -c $appleDisplClass | xpath -q -n -e "$prodNameQuery"))
|
|
|
|
|
|
|
|
|
|
if [[ "${#prods[@]}" -ge 2 ]]; then
|
|
|
|
|
echo ' Monitors '
|
|
|
|
|
echo '------------------------------------'
|
|
|
|
|
echo ' Index | VendorID | ProductID '
|
|
|
|
|
echo '------------------------------------'
|
|
|
|
|
# Show monitors.
|
|
|
|
|
for prod in "${prods[@]}"; do
|
|
|
|
|
MonitorName=${prodnames[$index]}
|
|
|
|
|
VendorID=${vends[$index]}
|
|
|
|
|
ProductID=${prods[$index]}
|
|
|
|
|
let index++
|
|
|
|
|
printf " %d | ${VendorID} | ${ProductID} | ${MonitorName}\n" ${index}
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "------------------------------------"
|
|
|
|
|
|
|
|
|
|
# Let user make a selection.
|
|
|
|
|
|
|
|
|
|
read -p "Choose the display:" selection
|
|
|
|
|
case $selection in
|
|
|
|
|
[[:digit:]]*)
|
|
|
|
|
if ((selection < 1 || selection > index)); then
|
|
|
|
|
echo "Enter error, bye"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
let selection-=1
|
|
|
|
|
dispid=$selection
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
echo "Enter error, bye"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
else
|
|
|
|
|
# One monitor detected
|
|
|
|
|
dispid=0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
VendorID=${vends[$dispid]}
|
|
|
|
|
ProductID=${prods[$dispid]}
|
|
|
|
|
Vid=($(printf '%x\n' ${VendorID}))
|
|
|
|
|
Pid=($(printf '%x\n' ${ProductID}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_vidpid_applesilicon
|
|
|
|
|
|
|
|
|
|
CCC
|
|
|
|
|
else
|
|
|
|
|
cat >"$(cd && pwd)/.hidpi-disable" <<-\CCC
|
2020-11-15 18:50:08 -06:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
function get_edid() {
|
2019-01-23 12:53:19 -06:00
|
|
|
|
local index=0
|
|
|
|
|
local selection=0
|
|
|
|
|
gDisplayInf=($(ioreg -lw0 | grep -i "IODisplayEDID" | sed -e "/[^<]*</s///" -e "s/\>//"))
|
|
|
|
|
if [[ "${#gDisplayInf[@]}" -ge 2 ]]; then
|
2019-11-18 14:47:08 -06:00
|
|
|
|
echo ' Monitors '
|
|
|
|
|
echo '------------------------------------'
|
|
|
|
|
echo ' Index | VendorID | ProductID '
|
|
|
|
|
echo '------------------------------------'
|
2020-11-15 18:50:08 -06:00
|
|
|
|
for display in "${gDisplayInf[@]}"; do
|
2019-01-23 12:53:19 -06:00
|
|
|
|
let index++
|
2021-03-02 00:15:45 -06:00
|
|
|
|
printf " %d | ${display:16:4} | ${display:22:2}${display:20:2}\n" $index
|
2019-01-23 12:53:19 -06:00
|
|
|
|
done
|
2019-11-18 14:47:08 -06:00
|
|
|
|
echo '------------------------------------'
|
2019-01-23 12:53:19 -06:00
|
|
|
|
read -p "Choose the display: " selection
|
|
|
|
|
case $selection in
|
2020-11-15 18:50:08 -06:00
|
|
|
|
[[:digit:]]*)
|
|
|
|
|
if ((selection < 1 || selection > index)); then
|
|
|
|
|
echo "Enter error, bye"
|
2020-07-06 03:56:41 -05:00
|
|
|
|
exit 1
|
2020-11-15 18:50:08 -06:00
|
|
|
|
fi
|
|
|
|
|
let selection-=1
|
|
|
|
|
gMonitor=${gDisplayInf[$selection]}
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "Enter error, bye"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
2019-01-23 12:53:19 -06:00
|
|
|
|
esac
|
|
|
|
|
else
|
|
|
|
|
gMonitor=${gDisplayInf}
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
EDID=$gMonitor
|
2019-11-18 14:47:08 -06:00
|
|
|
|
VendorID=$((0x${gMonitor:16:4}))
|
|
|
|
|
ProductID=$((0x${gMonitor:22:2}${gMonitor:20:2}))
|
|
|
|
|
Vid=($(printf '%x\n' ${VendorID}))
|
|
|
|
|
Pid=($(printf '%x\n' ${ProductID}))
|
2019-01-23 12:53:19 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_edid
|
|
|
|
|
|
2022-08-26 04:53:23 -05:00
|
|
|
|
CCC
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cat >>"$(cd && pwd)/.hidpi-disable" <<-\CCC
|
|
|
|
|
# Check if monitor was found
|
|
|
|
|
if [[ -z $VendorID || -z $ProductID || $VendorID == 0 || $ProductID == 0 ]]; then
|
|
|
|
|
echo "No monitors found. Exiting..."
|
|
|
|
|
exit 2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Your monitor VID/PID: $Vid:$Pid"
|
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
rootPath="../.."
|
|
|
|
|
restorePath="${rootPath}/Library/Displays/Contents/Resources/Overrides"
|
2019-01-23 12:53:19 -06:00
|
|
|
|
|
2020-07-06 03:56:41 -05:00
|
|
|
|
echo ""
|
2020-07-06 04:39:03 -05:00
|
|
|
|
echo "(1) Disable HIDPI on this monitor"
|
|
|
|
|
echo "(2) Reset all settings to macOS default"
|
2020-07-06 03:56:41 -05:00
|
|
|
|
echo ""
|
|
|
|
|
|
2020-07-06 04:39:03 -05:00
|
|
|
|
read -p "Enter your choice [1~2]: " input
|
2020-07-06 03:56:41 -05:00
|
|
|
|
case ${input} in
|
2020-11-15 18:50:08 -06:00
|
|
|
|
1)
|
|
|
|
|
if [[ -f "${restorePath}/Icons.plist" ]]; then
|
|
|
|
|
${rootPath}/usr/libexec/plistbuddy -c "Delete :vendors:${Vid}:products:${Pid}" "${restorePath}/Icons.plist"
|
|
|
|
|
fi
|
|
|
|
|
if [[ -d "${restorePath}/DisplayVendorID-${Vid}" ]]; then
|
|
|
|
|
rm -rf "${restorePath}/DisplayVendorID-${Vid}"
|
|
|
|
|
fi
|
2020-07-06 03:56:41 -05:00
|
|
|
|
;;
|
2020-11-15 18:50:08 -06:00
|
|
|
|
2)
|
|
|
|
|
rm -rf "${restorePath}"
|
2020-07-06 03:56:41 -05:00
|
|
|
|
;;
|
2020-11-15 18:50:08 -06:00
|
|
|
|
*)
|
2020-07-06 03:56:41 -05:00
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
echo "Enter error, bye"
|
2020-07-06 03:56:41 -05:00
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2019-01-23 12:53:19 -06:00
|
|
|
|
|
|
|
|
|
echo "HIDPI Disabled"
|
|
|
|
|
CCC
|
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
chmod +x "$(cd && pwd)/.hidpi-disable"
|
2019-01-23 12:53:19 -06:00
|
|
|
|
|
2018-04-02 13:59:50 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-10 11:03:20 -05:00
|
|
|
|
# choose_icon
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function choose_icon() {
|
|
|
|
|
|
2020-11-15 05:26:11 -06:00
|
|
|
|
rm -rf ${currentDir}/tmp/
|
|
|
|
|
mkdir -p ${currentDir}/tmp/
|
|
|
|
|
mkdir -p ${currentDir}/tmp/DisplayVendorID-${Vid}
|
|
|
|
|
curl -fsSL "${downloadHost}/Icons.plist" -o ${currentDir}/tmp/Icons.plist
|
2019-07-30 11:23:11 -05:00
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo "-------------------------------------"
|
|
|
|
|
echo "|********** ${langChooseIcon} ***********|"
|
|
|
|
|
echo "-------------------------------------"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "(1) iMac"
|
|
|
|
|
echo "(2) MacBook"
|
|
|
|
|
echo "(3) MacBook Pro"
|
|
|
|
|
echo "(4) LG ${langDisplay}"
|
|
|
|
|
echo "(5) Pro Display XDR"
|
|
|
|
|
echo "(6) ${langNotChange}"
|
|
|
|
|
echo ""
|
2020-11-15 18:50:08 -06:00
|
|
|
|
|
|
|
|
|
read -p "${langInputChoice} [1~6]: " logo
|
|
|
|
|
case ${logo} in
|
|
|
|
|
1)
|
|
|
|
|
Picon=${imacicon}
|
2019-01-23 12:53:19 -06:00
|
|
|
|
RP=("33" "68" "160" "90")
|
2020-11-15 05:26:11 -06:00
|
|
|
|
curl -fsSL "${downloadHost}/displayIcons/iMac.icns" -o ${currentDir}/tmp/DisplayVendorID-${Vid}/DisplayProductID-${Pid}.icns
|
2019-01-23 12:53:19 -06:00
|
|
|
|
;;
|
2020-11-15 18:50:08 -06:00
|
|
|
|
2)
|
|
|
|
|
Picon=${mbicon}
|
2019-01-23 12:53:19 -06:00
|
|
|
|
RP=("52" "66" "122" "76")
|
2020-11-15 05:26:11 -06:00
|
|
|
|
curl -fsSL "${downloadHost}/displayIcons/MacBook.icns" -o ${currentDir}/tmp/DisplayVendorID-${Vid}/DisplayProductID-${Pid}.icns
|
2019-01-23 12:53:19 -06:00
|
|
|
|
;;
|
2020-11-15 18:50:08 -06:00
|
|
|
|
3)
|
|
|
|
|
Picon=${mbpicon}
|
2019-01-23 12:53:19 -06:00
|
|
|
|
RP=("40" "62" "147" "92")
|
2020-11-15 05:26:11 -06:00
|
|
|
|
curl -fsSL "${downloadHost}/displayIcons/MacBookPro.icns" -o ${currentDir}/tmp/DisplayVendorID-${Vid}/DisplayProductID-${Pid}.icns
|
2019-01-23 12:53:19 -06:00
|
|
|
|
;;
|
2020-11-15 18:50:08 -06:00
|
|
|
|
4)
|
|
|
|
|
Picon=${lgicon}
|
2019-01-23 12:53:19 -06:00
|
|
|
|
RP=("11" "47" "202" "114")
|
2020-11-15 05:26:11 -06:00
|
|
|
|
cp ${sysDisplayDir}/DisplayVendorID-1e6d/DisplayProductID-5b11.icns ${currentDir}/tmp/DisplayVendorID-${Vid}/DisplayProductID-${Pid}.icns
|
2019-07-30 11:23:11 -05:00
|
|
|
|
;;
|
2020-11-15 18:50:08 -06:00
|
|
|
|
5)
|
|
|
|
|
Picon=${proxdricon}
|
2019-07-30 11:23:11 -05:00
|
|
|
|
RP=("5" "45" "216" "121")
|
2020-11-15 05:26:11 -06:00
|
|
|
|
curl -fsSL "${downloadHost}/displayIcons/ProDisplayXDR.icns" -o ${currentDir}/tmp/DisplayVendorID-${Vid}/DisplayProductID-${Pid}.icns
|
|
|
|
|
if [[ ! -f ${targetDir}/DisplayVendorID-610/DisplayProductID-ae2f_Landscape.tiff ]]; then
|
|
|
|
|
curl -fsSL "${downloadHost}/displayIcons/ProDisplayXDR.tiff" -o ${currentDir}/tmp/DisplayVendorID-${Vid}/DisplayProductID-${Pid}.tiff
|
2019-07-30 11:23:11 -05:00
|
|
|
|
Picon=${Overrides}"\/DisplayVendorID\-${Vid}\/DisplayProductID\-${Pid}\.tiff"
|
|
|
|
|
fi
|
2019-01-23 12:53:19 -06:00
|
|
|
|
;;
|
2020-11-15 18:50:08 -06:00
|
|
|
|
6)
|
|
|
|
|
rm -rf ${currentDir}/tmp/Icons.plist
|
2019-01-23 12:53:19 -06:00
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
echo "${langEnterError}"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
if [[ ${Picon} ]]; then
|
|
|
|
|
DICON=${Overrides}"\/DisplayVendorID\-${Vid}\/DisplayProductID\-${Pid}\.icns"
|
|
|
|
|
/usr/bin/sed -i "" "s/VID/${Vid}/g" ${currentDir}/tmp/Icons.plist
|
|
|
|
|
/usr/bin/sed -i "" "s/PID/${Pid}/g" ${currentDir}/tmp/Icons.plist
|
|
|
|
|
/usr/bin/sed -i "" "s/RPX/${RP[0]}/g" ${currentDir}/tmp/Icons.plist
|
|
|
|
|
/usr/bin/sed -i "" "s/RPY/${RP[1]}/g" ${currentDir}/tmp/Icons.plist
|
|
|
|
|
/usr/bin/sed -i "" "s/RPW/${RP[2]}/g" ${currentDir}/tmp/Icons.plist
|
|
|
|
|
/usr/bin/sed -i "" "s/RPH/${RP[3]}/g" ${currentDir}/tmp/Icons.plist
|
|
|
|
|
/usr/bin/sed -i "" "s/PICON/${Picon}/g" ${currentDir}/tmp/Icons.plist
|
|
|
|
|
/usr/bin/sed -i "" "s/DICON/${DICON}/g" ${currentDir}/tmp/Icons.plist
|
|
|
|
|
fi
|
2018-04-02 13:59:50 -05:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-04 03:24:19 -05:00
|
|
|
|
# main
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function main() {
|
2020-11-15 05:26:11 -06:00
|
|
|
|
sudo mkdir -p ${currentDir}/tmp/DisplayVendorID-${Vid}
|
|
|
|
|
dpiFile=${currentDir}/tmp/DisplayVendorID-${Vid}/DisplayProductID-${Pid}
|
|
|
|
|
sudo chmod -R 777 ${currentDir}/tmp/
|
2018-04-02 13:59:50 -05:00
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
cat >"${dpiFile}" <<-\CCC
|
2018-04-02 13:59:50 -05:00
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
|
<plist version="1.0">
|
|
|
|
|
<dict>
|
|
|
|
|
<key>DisplayProductID</key>
|
|
|
|
|
<integer>PID</integer>
|
|
|
|
|
<key>DisplayVendorID</key>
|
|
|
|
|
<integer>VID</integer>
|
|
|
|
|
<key>IODisplayEDID</key>
|
2018-04-02 15:30:49 -05:00
|
|
|
|
<data>EDid</data>
|
2018-04-02 13:59:50 -05:00
|
|
|
|
<key>scale-resolutions</key>
|
|
|
|
|
<array>
|
2018-06-10 11:03:20 -05:00
|
|
|
|
CCC
|
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
echo ""
|
|
|
|
|
echo "------------------------------------------"
|
|
|
|
|
echo "|********** "${langChooseRes}" ***********|"
|
|
|
|
|
echo "------------------------------------------"
|
|
|
|
|
echo ${langChooseResOp1}
|
|
|
|
|
echo ${langChooseResOp2}
|
|
|
|
|
echo ${langChooseResOp3}
|
|
|
|
|
echo ${langChooseResOp4}
|
|
|
|
|
echo ${langChooseResOp5}
|
|
|
|
|
echo ${langChooseResOpCustom}
|
|
|
|
|
echo ""
|
2018-06-10 11:03:20 -05:00
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
read -p "${langInputChoice}: " res
|
|
|
|
|
case ${res} in
|
|
|
|
|
1)
|
|
|
|
|
create_res_1 1680x945 1440x810 1280x720 1024x576
|
2019-08-17 11:44:03 -05:00
|
|
|
|
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
|
2020-11-15 18:50:08 -06:00
|
|
|
|
;;
|
|
|
|
|
2)
|
|
|
|
|
create_res_1 1680x945 1424x802 1280x720 1024x576
|
2019-08-17 11:44:03 -05:00
|
|
|
|
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
|
2020-11-15 18:50:08 -06:00
|
|
|
|
;;
|
|
|
|
|
3)
|
|
|
|
|
create_res_1 1680x1050 1440x900 1280x800 1024x640
|
2019-08-17 11:44:03 -05:00
|
|
|
|
create_res_2 1280x800 1280x720 960x600 960x540 640x360
|
|
|
|
|
create_res_3 840x472 800x450 720x405 640x360 576x324 512x288 420x234 400x225 320x180
|
|
|
|
|
create_res_4 1680x1050 1440x900 1280x800 1024x640 960x540 840x472 800x450 640x360
|
2020-11-15 18:50:08 -06:00
|
|
|
|
;;
|
|
|
|
|
4)
|
|
|
|
|
create_res_1 2560x1440 2048x1152 1920x1080 1760x990 1680x945 1440x810 1360x765 1280x720
|
2019-08-17 11:44:03 -05:00
|
|
|
|
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
|
2020-11-15 18:50:08 -06:00
|
|
|
|
;;
|
|
|
|
|
5)
|
|
|
|
|
create_res_1 3000x2000 2880x1920 2250x1500 1920x1280 1680x1050 1440x900 1280x800 1024x640
|
2019-08-17 11:44:03 -05:00
|
|
|
|
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
|
2020-11-15 18:50:08 -06:00
|
|
|
|
;;
|
|
|
|
|
6)
|
|
|
|
|
custom_res
|
2019-08-17 11:44:03 -05:00
|
|
|
|
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
|
2020-11-15 18:50:08 -06:00
|
|
|
|
;;
|
2019-08-17 11:44:03 -05:00
|
|
|
|
*)
|
2020-11-15 18:50:08 -06:00
|
|
|
|
echo "${langEnterError}"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2018-06-10 11:03:20 -05:00
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
cat >>"${dpiFile}" <<-\FFF
|
2018-06-10 11:03:20 -05:00
|
|
|
|
</array>
|
2018-04-02 13:59:50 -05:00
|
|
|
|
<key>target-default-ppmm</key>
|
2018-06-07 20:12:54 -05:00
|
|
|
|
<real>10.0699301</real>
|
2018-04-02 13:59:50 -05:00
|
|
|
|
</dict>
|
|
|
|
|
</plist>
|
2018-06-10 11:03:20 -05:00
|
|
|
|
FFF
|
2018-04-02 13:59:50 -05:00
|
|
|
|
|
2019-07-30 11:23:11 -05:00
|
|
|
|
/usr/bin/sed -i "" "s/VID/$VendorID/g" ${dpiFile}
|
|
|
|
|
/usr/bin/sed -i "" "s/PID/$ProductID/g" ${dpiFile}
|
2018-04-02 15:30:49 -05:00
|
|
|
|
}
|
2018-04-02 13:59:50 -05:00
|
|
|
|
|
2018-06-10 11:03:20 -05:00
|
|
|
|
# end
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function end() {
|
2020-11-15 05:26:11 -06:00
|
|
|
|
sudo chown -R root:wheel ${currentDir}/tmp/
|
|
|
|
|
sudo chmod -R 0755 ${currentDir}/tmp/
|
|
|
|
|
sudo chmod 0644 ${currentDir}/tmp/DisplayVendorID-${Vid}/*
|
|
|
|
|
sudo cp -r ${currentDir}/tmp/* ${targetDir}/
|
|
|
|
|
sudo rm -rf ${currentDir}/tmp
|
2019-08-17 11:44:03 -05:00
|
|
|
|
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES
|
2019-07-30 11:23:11 -05:00
|
|
|
|
echo "${langEnabled}"
|
|
|
|
|
echo "${langEnabledLog}"
|
2018-04-02 15:30:49 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-10 11:03:20 -05:00
|
|
|
|
# custom resolution
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function custom_res() {
|
2019-07-30 11:23:11 -05:00
|
|
|
|
echo "${langCustomRes}"
|
2018-06-10 11:03:20 -05:00
|
|
|
|
read -p ":" res
|
2019-07-30 11:23:11 -05:00
|
|
|
|
create_res ${res}
|
2018-06-10 11:03:20 -05:00
|
|
|
|
}
|
2018-06-07 20:12:54 -05:00
|
|
|
|
|
2018-06-10 11:03:20 -05:00
|
|
|
|
# create resolution
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function create_res() {
|
2018-06-10 11:03:20 -05:00
|
|
|
|
for res in $@; do
|
2020-11-15 18:50:08 -06:00
|
|
|
|
width=$(echo ${res} | cut -d x -f 1)
|
|
|
|
|
height=$(echo ${res} | cut -d x -f 2)
|
|
|
|
|
hidpi=$(printf '%08x %08x' $((${width} * 2)) $((${height} * 2)) | xxd -r -p | base64)
|
|
|
|
|
#
|
|
|
|
|
cat <<OOO >>${dpiFile}
|
2018-08-05 07:00:58 -05:00
|
|
|
|
<data>${hidpi:0:11}AAAAB</data>
|
|
|
|
|
<data>${hidpi:0:11}AAAABACAAAA==</data>
|
|
|
|
|
OOO
|
2020-11-15 18:50:08 -06:00
|
|
|
|
done
|
2018-08-05 07:00:58 -05:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function create_res_1() {
|
2018-08-05 07:00:58 -05:00
|
|
|
|
for res in $@; do
|
2020-11-15 18:50:08 -06:00
|
|
|
|
width=$(echo ${res} | cut -d x -f 1)
|
|
|
|
|
height=$(echo ${res} | cut -d x -f 2)
|
|
|
|
|
hidpi=$(printf '%08x %08x' $((${width} * 2)) $((${height} * 2)) | xxd -r -p | base64)
|
|
|
|
|
#
|
|
|
|
|
cat <<OOO >>${dpiFile}
|
2018-06-10 11:03:20 -05:00
|
|
|
|
<data>${hidpi:0:11}A</data>
|
2018-08-05 07:00:58 -05:00
|
|
|
|
OOO
|
2020-11-15 18:50:08 -06:00
|
|
|
|
done
|
2018-08-05 07:00:58 -05:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function create_res_2() {
|
2018-08-05 07:00:58 -05:00
|
|
|
|
for res in $@; do
|
2020-11-15 18:50:08 -06:00
|
|
|
|
width=$(echo ${res} | cut -d x -f 1)
|
|
|
|
|
height=$(echo ${res} | cut -d x -f 2)
|
|
|
|
|
hidpi=$(printf '%08x %08x' $((${width} * 2)) $((${height} * 2)) | xxd -r -p | base64)
|
|
|
|
|
#
|
|
|
|
|
cat <<OOO >>${dpiFile}
|
2018-06-10 11:03:20 -05:00
|
|
|
|
<data>${hidpi:0:11}AAAABACAAAA==</data>
|
2018-08-05 07:00:58 -05:00
|
|
|
|
OOO
|
2020-11-15 18:50:08 -06:00
|
|
|
|
done
|
2018-08-05 07:00:58 -05:00
|
|
|
|
}
|
2018-06-10 11:03:20 -05:00
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function create_res_3() {
|
2018-08-05 07:00:58 -05:00
|
|
|
|
for res in $@; do
|
2020-11-15 18:50:08 -06:00
|
|
|
|
width=$(echo ${res} | cut -d x -f 1)
|
|
|
|
|
height=$(echo ${res} | cut -d x -f 2)
|
|
|
|
|
hidpi=$(printf '%08x %08x' $((${width} * 2)) $((${height} * 2)) | xxd -r -p | base64)
|
|
|
|
|
#
|
|
|
|
|
cat <<OOO >>${dpiFile}
|
2018-08-05 07:00:58 -05:00
|
|
|
|
<data>${hidpi:0:11}AAAAB</data>
|
2018-06-10 11:03:20 -05:00
|
|
|
|
OOO
|
2020-11-15 18:50:08 -06:00
|
|
|
|
done
|
2018-08-05 07:00:58 -05:00
|
|
|
|
}
|
2018-06-07 20:12:54 -05:00
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function create_res_4() {
|
2018-08-05 07:00:58 -05:00
|
|
|
|
for res in $@; do
|
2020-11-15 18:50:08 -06:00
|
|
|
|
width=$(echo ${res} | cut -d x -f 1)
|
|
|
|
|
height=$(echo ${res} | cut -d x -f 2)
|
|
|
|
|
hidpi=$(printf '%08x %08x' $((${width} * 2)) $((${height} * 2)) | xxd -r -p | base64)
|
|
|
|
|
#
|
|
|
|
|
cat <<OOO >>${dpiFile}
|
2018-08-05 07:00:58 -05:00
|
|
|
|
<data>${hidpi:0:11}AAAAJAKAAAA==</data>
|
|
|
|
|
OOO
|
2020-11-15 18:50:08 -06:00
|
|
|
|
done
|
2018-06-10 11:03:20 -05:00
|
|
|
|
}
|
2018-06-07 20:12:54 -05:00
|
|
|
|
|
2018-06-10 11:03:20 -05:00
|
|
|
|
# enable
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function enable_hidpi() {
|
2018-04-02 15:30:49 -05:00
|
|
|
|
choose_icon
|
|
|
|
|
main
|
2019-07-30 11:23:11 -05:00
|
|
|
|
sed -i "" "/.*IODisplayEDID/d" ${dpiFile}
|
|
|
|
|
sed -i "" "/.*EDid/d" ${dpiFile}
|
2018-04-02 15:30:49 -05:00
|
|
|
|
end
|
|
|
|
|
}
|
2018-04-02 13:59:50 -05:00
|
|
|
|
|
2018-06-10 11:03:20 -05:00
|
|
|
|
# patch
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function enable_hidpi_with_patch() {
|
2018-04-02 15:30:49 -05:00
|
|
|
|
choose_icon
|
|
|
|
|
main
|
2019-02-17 06:52:19 -06:00
|
|
|
|
|
|
|
|
|
version=${EDID:38:2}
|
|
|
|
|
basicparams=${EDID:40:2}
|
|
|
|
|
checksum=${EDID:254:2}
|
2020-11-15 18:50:08 -06:00
|
|
|
|
newchecksum=$(printf '%x' $((0x${checksum} + 0x${version} + 0x${basicparams} - 0x04 - 0x90)) | tail -c 2)
|
2019-11-18 14:47:08 -06:00
|
|
|
|
newedid=${EDID:0:38}0490${EDID:42:6}e6${EDID:50:204}${newchecksum}
|
2019-07-30 11:23:11 -05:00
|
|
|
|
EDid=$(printf ${newedid} | xxd -r -p | base64)
|
2019-02-17 06:52:19 -06:00
|
|
|
|
|
2019-07-30 11:23:11 -05:00
|
|
|
|
/usr/bin/sed -i "" "s:EDid:${EDid}:g" ${dpiFile}
|
2018-04-02 15:30:49 -05:00
|
|
|
|
end
|
2018-04-02 13:59:50 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-10 11:03:20 -05:00
|
|
|
|
# disable
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function disable() {
|
2020-07-06 03:56:41 -05:00
|
|
|
|
echo ""
|
|
|
|
|
echo "${langDisableOpt1}"
|
|
|
|
|
echo "${langDisableOpt2}"
|
|
|
|
|
echo ""
|
2020-07-06 01:04:45 -05:00
|
|
|
|
|
2020-07-06 03:56:41 -05:00
|
|
|
|
read -p "${langInputChoice} [1~2]: " input
|
|
|
|
|
case ${input} in
|
2020-11-15 18:50:08 -06:00
|
|
|
|
1)
|
|
|
|
|
if [[ -f "${targetDir}/Icons.plist" ]]; then
|
|
|
|
|
sudo /usr/libexec/plistbuddy -c "Delete :vendors:${Vid}:products:${Pid}" "${targetDir}/Icons.plist"
|
|
|
|
|
fi
|
|
|
|
|
if [[ -d "${targetDir}/DisplayVendorID-${Vid}" ]]; then
|
|
|
|
|
sudo rm -rf "${targetDir}/DisplayVendorID-${Vid}"
|
|
|
|
|
fi
|
2020-07-06 03:56:41 -05:00
|
|
|
|
;;
|
2020-11-15 18:50:08 -06:00
|
|
|
|
2)
|
|
|
|
|
sudo rm -rf "${targetDir}"
|
2020-07-06 03:56:41 -05:00
|
|
|
|
;;
|
2020-11-15 18:50:08 -06:00
|
|
|
|
*)
|
2020-07-06 03:56:41 -05:00
|
|
|
|
|
2020-11-15 18:50:08 -06:00
|
|
|
|
echo "${langEnterError}"
|
2020-07-06 03:56:41 -05:00
|
|
|
|
exit 1
|
|
|
|
|
;;
|
2020-11-15 18:50:08 -06:00
|
|
|
|
esac
|
2019-01-23 12:53:19 -06:00
|
|
|
|
|
2019-07-30 11:23:11 -05:00
|
|
|
|
echo "${langDisabled}"
|
2018-04-02 13:59:50 -05:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 12:53:19 -06:00
|
|
|
|
#
|
2020-11-15 18:50:08 -06:00
|
|
|
|
function start() {
|
2018-04-02 13:59:50 -05:00
|
|
|
|
init
|
2019-07-30 11:23:11 -05:00
|
|
|
|
echo ""
|
2022-08-26 04:53:23 -05:00
|
|
|
|
let opt++; printf "${langEnableHIDPI}\n" $opt
|
|
|
|
|
if [[ $is_applesilicon == false ]]; then
|
|
|
|
|
let opt++; printf "${langEnableHIDPIEDID}\n" $opt
|
|
|
|
|
fi
|
|
|
|
|
let opt++; printf "${langDisableHIDPI}\n" $opt
|
2019-07-30 11:23:11 -05:00
|
|
|
|
echo ""
|
2018-04-02 13:59:50 -05:00
|
|
|
|
|
2022-08-26 04:53:23 -05:00
|
|
|
|
read -p "${langInputChoice} [1~$opt]: " input
|
|
|
|
|
if [[ $is_applesilicon == true ]]; then
|
|
|
|
|
case ${input} in
|
|
|
|
|
1)
|
|
|
|
|
enable_hidpi
|
|
|
|
|
;;
|
|
|
|
|
2)
|
|
|
|
|
disable
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "${langEnterError}"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
else
|
|
|
|
|
case ${input} in
|
|
|
|
|
1)
|
|
|
|
|
enable_hidpi
|
|
|
|
|
;;
|
|
|
|
|
2)
|
|
|
|
|
enable_hidpi_with_patch
|
|
|
|
|
;;
|
|
|
|
|
3)
|
|
|
|
|
disable
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "${langEnterError}"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
fi
|
2019-01-23 12:53:19 -06:00
|
|
|
|
}
|
2018-04-02 13:59:50 -05:00
|
|
|
|
|
|
|
|
|
start
|