From d6ca677a4fa8bb23e90e64e861bd59db8879c2fa Mon Sep 17 00:00:00 2001 From: xzhih <842708096@qq.com> Date: Thu, 24 Jan 2019 02:53:19 +0800 Subject: [PATCH] add new restore way --- README-zh.md | 42 +++++-- README.md | 44 ++++++-- hidpi-zh.sh | 304 +++++++++++++++++++++++++++++++-------------------- hidpi.sh | 277 ++++++++++++++++++++++++++++------------------ 4 files changed, 421 insertions(+), 246 deletions(-) diff --git a/README-zh.md b/README-zh.md index 4da10f5..8b61b9d 100644 --- a/README-zh.md +++ b/README-zh.md @@ -20,24 +20,48 @@ macOS 的 DPI 机制和 Windows 下不一样,比如 1080p 的屏幕在 Windows 在终端输入以下命令回车即可 -``` -$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/xzhih/one-key-hidpi/master/hidpi-zh.sh)" +```bash +sh -c "$(curl -fsSL https://raw.githubusercontent.com/xzhih/one-key-hidpi/master/hidpi-zh.sh)" ``` ![运行](./img/run-zh.jpg) ## 恢复 -如果使用此脚本后,开机无法进入系统,请到恢复模式中或使用 clover `-x` 安全模式进入系统 ,使用终端删除 `/System/Library/Displays/Contents/Resources/Overrides` 下删除显示器 VendorID 对应的文件夹,并把 backup 文件夹中的备份复制出来。 +### 命令恢复 + +如果还能进系统,就再次运行命令选择选项 3 关闭 HIDPI。 + +### 恢复模式 + +如果使用此脚本后,开机无法进入系统,请到 macos 恢复模式中或使用 clover `-x` 安全模式进入系统,打开终端 + +这里有两种方式进行关闭,建议选第一种 + +1. 快捷恢复 + +```bash +ls /Volumes/ +cd /Volumes/你的系统盘/System/Library/Displays/Contents/Resources/Overrides/HIDPI + +./disable +``` + +2. 手动恢复 + +使用终端删除 `/System/Library/Displays/Contents/Resources/Overrides` 下删除显示器 VendorID 对应的文件夹,并把 `HIDPI/backup` 文件夹中的备份复制出来。 + +请使用单个显示器执行以下命令,笔记本关闭外接显示器的 HIDPI 时请关闭内置显示器 具体命令如下: -``` -$ cd /Volumes/你的系统盘/System/Library/Displays/Contents/Resources/Overrides -$ VendorID=$(ioreg -l | grep "DisplayVendorID" | awk '{print $8}') -$ Vid=$(echo "obase=16;$VendorID" | bc | tr 'A-Z' 'a-z') -$ rm -rf ./DisplayVendorID-$Vid -$ cp -r ./backup/* ./ +```bash +ls /Volumes/ +cd /Volumes/你的系统盘/System/Library/Displays/Contents/Resources/Overrides +EDID=($(ioreg -lw0 | grep -i "IODisplayEDID" | sed -e "/[^<]*//")) +Vid=($(echo $EDID | cut -c18-20)) +rm -rf ./DisplayVendorID-$Vid +cp -r ./HIDPI/backup/* ./ ``` ## 从以下得到启发 diff --git a/README.md b/README.md index db1bc46..7361230 100755 --- a/README.md +++ b/README.md @@ -16,26 +16,50 @@ System Preferences ## Usage -Run script in Terminal +Run this script in Terminal -``` -$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/xzhih/one-key-hidpi/master/hidpi.sh)" +```bash +sh -c "$(curl -fsSL https://raw.githubusercontent.com/xzhih/one-key-hidpi/master/hidpi.sh)" ``` ![RUN](./img/run.jpg) ## Recovery -If you cant boot into system, or get any another issues, you can use clover `-x ` reboot or into Recovery mode, remove your display's DisplayVendorID folder under `/System/Library/Displays/Contents/Resources/Overrides` , and move backup files +### Normal + +Still running the script in the terminal, but choose option 3 + +### Recovery mode + +If you cant boot into system, or get any another issues, you can boot into macOS Recovery mode, and use the Terminal.app + +There are two ways to close it. It is recommended to choose the first one + +1. + +```bash +ls /Volumes/ +cd /Volumes/"Your System Disk Part"/System/Library/Displays/Contents/Resources/Overrides/HIDPI + +./disable +``` + +2. + +Remove your display's DisplayVendorID folder under `/System/Library/Displays/Contents/Resources/Overrides` , and move backup files + +Please use the single display to execute the following commands. If it is a laptop, turn off the internal monitor when turning off the HIDPI of the external monitor. In Terminal: -``` -$ cd /Volumes/"Your System Disk Part"/System/Library/Displays/Contents/Resources/Overrides -$ VendorID=$(ioreg -l | grep "DisplayVendorID" | awk '{print $8}') -$ Vid=$(echo "obase=16;$VendorID" | bc | tr 'A-Z' 'a-z') -$ rm -rf ./DisplayVendorID-$Vid -$ cp -r ./backup/* ./ +```bash +ls /Volumes/ +cd /Volumes/"Your System Disk Part"/System/Library/Displays/Contents/Resources/Overrides +EDID=($(ioreg -lw0 | grep -i "IODisplayEDID" | sed -e "/[^<]*//")) +Vid=($(echo $EDID | cut -c18-20)) +rm -rf ./DisplayVendorID-$Vid +cp -r ./HIDPI/backup/* ./ ``` ## Inspired diff --git a/hidpi-zh.sh b/hidpi-zh.sh index e1de1d6..dfe1a05 100755 --- a/hidpi-zh.sh +++ b/hidpi-zh.sh @@ -1,19 +1,5 @@ #!/bin/sh -# -# Output styling. -# -BOLD="\033[1m" -RED="\033[1;31m" -GREEN="\033[1;32m" -BLUE="\033[1;34m" -OFF="\033[m" -STYLE_UNDERLINED="\e[4m" -# -function _toLowerCase() -{ - echo "`echo $1 | tr '[:upper:]' '[:lower:]'`" -} -# + function get_edid() { local index=0 @@ -21,79 +7,61 @@ function get_edid() gDisplayInf=($(ioreg -lw0 | grep -i "IODisplayEDID" | sed -e "/[^<]*//")) - if [[ "${#gDisplayInf[@]}" -ge 2 ]]; - then - # + if [[ "${#gDisplayInf[@]}" -ge 2 ]]; then + # Multi monitors detected. Choose target monitor. - # + echo '' echo ' 显示器列表 ' echo '------------------------------------' echo ' 序号 | VendorID | ProductID ' echo '------------------------------------' + + # Show monitors. for display in "${gDisplayInf[@]}" do - let index++ - # - # Show monitors. - # - printf " %d | ${display:16:4} | ${display:20:4}\n" $index + let index++ + printf " %d | ${display:16:4} | ${display:20:4}\n" $index done - # - # Close the table - # + echo '------------------------------------' - # + # Let user make a selection. - # - printf '请选择需要开启HiDPI的显示器序号' - if [[ "${#gDisplayInf[@]}" == 2 ]]; then - printf "[$RED${STYLE_UNDERLINED}E${OFF}xit/1/2]" - else - printf "[$RED${STYLE_UNDERLINED}E${OFF}xit/1-${index}]" - fi - read -p ": " selection - case "$(_toLowerCase $selection)" in - e|exit ) echo "Abort." - exit -0 - ;; - [[:digit:]]* ) # - # Lower selection (arrays start at zero). - # - if ((selection < 1 || selection > index)); then - echo "Enter error, bye"; - exit 0 - fi - let selection-=1 - gMonitor=${gDisplayInf[$selection]} - ;; + read -p "选择显示器序号: " selection + case $selection in + [[:digit:]]* ) + # Lower selection (arrays start at zero). + if ((selection < 1 || selection > index)); then + echo "输入错误,拜拜"; + exit 0 + fi + let selection-=1 + gMonitor=${gDisplayInf[$selection]} + ;; - * ) if [[ "${#gDisplayInf[@]}" == 2 ]]; then - echo 'Invalid menu action, enter 1 or 2' - else - echo "Invalid menu action, enter valid number among 1, ..., ${index}" - fi - ;; + * ) + echo "输入错误,拜拜"; + exit 0 + ;; esac - else + else gMonitor=${gDisplayInf} fi - # - # + if [[ ${gMonitor:16:1} == 0 ]]; then # get rid of the prefix 0 gDisplayVendorID_RAW=${gMonitor:17:3} else gDisplayVendorID_RAW=${gMonitor:16:4} 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} @@ -104,22 +72,21 @@ function get_edid() gDisplayProductID_reverse="${gDisplayProduct_pr}${gDisplayProduct_st}" gDisplayProductID=$((0x$gDisplayProduct_pr$gDisplayProduct_st)) - EDID=$gMonitor VendorID=$gDisplayVendorID - ProductID=$gDisplayProductID - # echo $VendorID - # echo $ProductID + ProductID=$gDisplayProductID + Vid=$gDisplayVendorID_RAW + Pid=$gDisplayProductID_reverse + # echo $Vid + # echo $Pid # echo $EDID } -# -# + # 初始化 function init() { # cat << EEF - _ _ _____ _____ _____ _____ | | | | |_ _| | __ \ | __ \ |_ _| | |__| | | | | | | | | |__) | | | @@ -128,15 +95,10 @@ cat << EEF |_| |_| |_____| |_____/ |_| |_____| ============================================ - - EEF # get_edid - - Vid=$(echo "obase=16;$VendorID" | bc | tr 'A-Z' 'a-z') - Pid=$(echo "obase=16;$ProductID" | bc | tr 'A-Z' 'a-z') - + edID=$(echo $EDID | sed 's/../b5/21') EDid=$(printf $edID | xxd -r -p | base64) @@ -150,14 +112,111 @@ EEF mbicon=${Overrides}"DisplayVendorID-610\/DisplayProductID-a028-9d9da0.tiff" lgicon=${Overrides}"DisplayVendorID-1e6d\/DisplayProductID-5b11.tiff" - if [[ ! -d $thatDir/backup ]]; then + if [[ ! -f $thatDir/HIDPI/disable ]]; then echo "正在备份" - sudo mkdir -p $thatDir/backup - sudo cp $thatDir/Icons.plist $thatDir/backup/ + sudo mkdir -p $thatDir/HIDPI/backup + sudo cp $thatDir/Icons.plist $thatDir/HIDPI/backup/ if [[ -d $thatDir/DisplayVendorID-$Vid ]]; then - sudo cp -r $thatDir/DisplayVendorID-$Vid $thatDir/backup/ + sudo cp -r $thatDir/DisplayVendorID-$Vid $thatDir/HIDPI/backup/ fi fi + + if [[ ! -f $thatDir/HIDPI/disable ]]; then + generate_restore_cmd + fi +} + +# +function generate_restore_cmd() +{ +# +rm -rf $thisDir/tmp/ +mkdir -p $thisDir/tmp/ +cat > "$thisDir/tmp/disable" <<-\CCC +function get_edid() +{ + local index=0 + local selection=0 + + gDisplayInf=($(ioreg -lw0 | grep -i "IODisplayEDID" | sed -e "/[^<]*//")) + + if [[ "${#gDisplayInf[@]}" -ge 2 ]]; then + + echo ' Monitors ' + echo '------------------------------------' + echo ' Index | VendorID | ProductID ' + echo '------------------------------------' + + for display in "${gDisplayInf[@]}" + do + let index++ + printf " %d | ${display:16:4} | ${display:20:4}\n" $index + done + + echo '------------------------------------' + + read -p "Choose the display: " selection + case $selection in + [[:digit:]]* ) + if ((selection < 1 || selection > index)); then + echo "Enter error, bye"; + exit 0 + fi + let selection-=1 + gMonitor=${gDisplayInf[$selection]} + ;; + + * ) + echo "Enter error, bye"; + exit 0 + ;; + esac + else + gMonitor=${gDisplayInf} + 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 + Vid=$gDisplayVendorID_RAW + Pid=$gDisplayProductID_reverse + # echo $Vid + # echo $Pid + # echo $EDID +} + +get_edid + +if [[ -d ../DisplayVendorID-$Vid ]]; then + rm -rf ../DisplayVendorID-$Vid +fi + +rm -rf ../Icons.plist +cp -r ./backup/* ../ +rm -rf ./disable +echo "HIDPI Disabled" +CCC + +sudo mv $thisDir/tmp/disable $thatDir/HIDPI/ +sudo chmod +x $thatDir/HIDPI/disable + } # 选择ICON @@ -185,25 +244,25 @@ EOF read -p "输入你的选择[1~5]: " logo case $logo in 1) Picon=$imacicon -RP=("33" "68" "160" "90") -;; -2) Picon=$mbicon -RP=("52" "66" "122" "76") -;; -3) Picon=$mbpicon -RP=("40" "62" "147" "92") -;; -4) Picon=$lgicon -RP=("11" "47" "202" "114") -DICON=${Overrides}"DisplayVendorID-1e6d\/DisplayProductID-5b11.icns" -;; -5) rm -rf $thisDir/tmp/Icons.plist -;; -*) - -echo "输入错误,拜拜"; -exit 0 -;; + RP=("33" "68" "160" "90") + ;; + 2) Picon=$mbicon + RP=("52" "66" "122" "76") + ;; + 3) Picon=$mbpicon + RP=("40" "62" "147" "92") + ;; + 4) Picon=$lgicon + RP=("11" "47" "202" "114") + DICON=${Overrides}"DisplayVendorID-1e6d\/DisplayProductID-5b11.icns" + ;; + 5) rm -rf $thisDir/tmp/Icons.plist + ;; + *) + + echo "输入错误,拜拜"; + exit 0 + ;; esac if [[ $Picon ]]; then @@ -254,19 +313,19 @@ EOF read -p "选择你想要的配置: " res case $res in - 1 ) create_res_1 1920x1080 1680x945 1440x810 1280x720 1024x576 -;; -2 ) create_res_1 2048x1152 1920x1080 1680x945 1440x810 1280x720 + 1 ) create_res_1 1680x944 1600x900 1440x810 1280x720 1024x576 + ;; + 2 ) create_res_1 2048x1152 1920x1080 1680x944 1440x810 1280x720 create_res_2 1024x576 create_res_3 960x540 - create_res_4 2048x1152 -;; -3 ) custom_res;; + create_res_4 2048x1152 1920x1080 + ;; + 3 ) custom_res;; esac -create_res_2 1280x720 960x540 640x360 -create_res_3 840x472 720x405 640x360 576x324 512x288 420x234 400x225 320x180 -create_res_4 1920x1080 1680x945 1440x810 1280x720 1024x576 960x540 640x360 +create_res_2 1280x800 1280x720 960x600 960x540 640x360 +create_res_3 840x472 800x450 720x405 640x360 576x324 512x288 420x234 400x225 320x180 +create_res_4 1680x944 1600x900 1440x810 1280x720 1024x576 960x540 840x472 800x450 640x360 cat >> "$dpiFile" <<-\FFF @@ -287,7 +346,6 @@ function end() sudo rm -rf $thisDir/tmp echo "开启成功,重启生效" echo "首次重启开机logo会变得巨大,之后就不会了" - # say "妖怪,哪里跑" } #自定义分辨率 @@ -387,13 +445,17 @@ function enable_hidpi_with_patch() # 关 function disable() { - sudo rm -rf $thatDir/DisplayVendorID-$Vid + if [[ -d $thatDir/DisplayVendorID-$Vid ]]; then + sudo rm -rf $thatDir/DisplayVendorID-$Vid + fi + sudo rm -rf $thatDir/Icons.plist - sudo cp -r $thatDir/backup/* $thatDir/ - sudo rm -rf $thatDir/backup + sudo cp -r $thatDir/HIDPI/backup/* $thatDir/ + sudo rm -rf $thatDir/HIDPI/disable echo "已关闭,重启生效" } +# function start() { init @@ -409,16 +471,16 @@ EOF read -p "输入你的选择[1~3]: " input case $input in 1) enable_hidpi -;; -2) enable_hidpi_with_patch -;; -3) disable -;; -*) - -echo "输入错误,拜拜"; -exit 0 -;; + ;; + 2) enable_hidpi_with_patch + ;; + 3) disable + ;; + *) + + echo "输入错误,拜拜"; + exit 0 + ;; esac } diff --git a/hidpi.sh b/hidpi.sh index 85bf9db..e66de2b 100755 --- a/hidpi.sh +++ b/hidpi.sh @@ -1,19 +1,5 @@ #!/bin/sh -# -# Output styling. -# -BOLD="\033[1m" -RED="\033[1;31m" -GREEN="\033[1;32m" -BLUE="\033[1;34m" -OFF="\033[m" -STYLE_UNDERLINED="\e[4m" -# -function _toLowerCase() -{ - echo "`echo $1 | tr '[:upper:]' '[:lower:]'`" -} -# + function get_edid() { local index=0 @@ -21,79 +7,61 @@ function get_edid() gDisplayInf=($(ioreg -lw0 | grep -i "IODisplayEDID" | sed -e "/[^<]*//")) - if [[ "${#gDisplayInf[@]}" -ge 2 ]]; - then - # + if [[ "${#gDisplayInf[@]}" -ge 2 ]]; then + # Multi monitors detected. Choose target monitor. - # - echo ' Table of monitors ' + echo '' + echo ' Monitors ' echo '------------------------------------' echo ' Index | VendorID | ProductID ' echo '------------------------------------' + + # Show monitors. for display in "${gDisplayInf[@]}" do - let index++ - # - # Show monitors. - # - printf " %d | ${display:16:4} | ${display:20:4}\n" $index + let index++ + printf " %d | ${display:16:4} | ${display:20:4}\n" $index done - # - # Close the table - # + echo '------------------------------------' - # + # Let user make a selection. - # - printf 'Choose the display to enable HiDPI' - if [[ "${#gDisplayInf[@]}" == 2 ]]; then - printf "[$RED${STYLE_UNDERLINED}E${OFF}xit/1/2]" - else - printf "[$RED${STYLE_UNDERLINED}E${OFF}xit/1-${index}]" - fi - read -p ": " selection - case "$(_toLowerCase $selection)" in - e|exit ) echo "Abort." - exit -0 - ;; - [[:digit:]]* ) # - # Lower selection (arrays start at zero). - # - if ((selection < 1 || selection > index)); then - echo "Enter error, bye"; - exit 0 - fi - let selection-=1 - gMonitor=${gDisplayInf[$selection]} - ;; + read -p "Choose the display: " selection + case $selection in + [[:digit:]]* ) + # Lower selection (arrays start at zero). + if ((selection < 1 || selection > index)); then + echo "Enter error, bye"; + exit 0 + fi + let selection-=1 + gMonitor=${gDisplayInf[$selection]} + ;; - * ) if [[ "${#gDisplayInf[@]}" == 2 ]]; then - echo 'Invalid menu action, enter 1 or 2' - else - echo "Invalid menu action, enter valid number among 1, ..., ${index}" - fi - ;; + * ) + echo "Enter error, bye"; + exit 0 + ;; esac - else + else gMonitor=${gDisplayInf} fi - # - # + if [[ ${gMonitor:16:1} == 0 ]]; then # get rid of the prefix 0 gDisplayVendorID_RAW=${gMonitor:17:3} else gDisplayVendorID_RAW=${gMonitor:16:4} 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} @@ -104,22 +72,21 @@ function get_edid() gDisplayProductID_reverse="${gDisplayProduct_pr}${gDisplayProduct_st}" gDisplayProductID=$((0x$gDisplayProduct_pr$gDisplayProduct_st)) - EDID=$gMonitor VendorID=$gDisplayVendorID - ProductID=$gDisplayProductID - # echo $VendorID - # echo $ProductID + ProductID=$gDisplayProductID + Vid=$gDisplayVendorID_RAW + Pid=$gDisplayProductID_reverse + # echo $Vid + # echo $Pid # echo $EDID } -# -# + # init function init() { # cat << EEF - _ _ _____ _____ _____ _____ | | | | |_ _| | __ \ | __ \ |_ _| | |__| | | | | | | | | |__) | | | @@ -128,15 +95,10 @@ cat << EEF |_| |_| |_____| |_____/ |_| |_____| ============================================ - - EEF # get_edid - - Vid=$(echo "obase=16;$VendorID" | bc | tr 'A-Z' 'a-z') - Pid=$(echo "obase=16;$ProductID" | bc | tr 'A-Z' 'a-z') - + edID=$(echo $EDID | sed 's/../b5/21') EDid=$(echo $edID | xxd -r -p | base64) @@ -150,14 +112,111 @@ EEF mbicon=${Overrides}"DisplayVendorID-610\/DisplayProductID-a028-9d9da0.tiff" lgicon=${Overrides}"DisplayVendorID-1e6d\/DisplayProductID-5b11.tiff" - if [[ ! -d $thatDir/backup ]]; then + if [[ ! -d $thatDir/HIDPI/backup ]]; then echo "Backing up..." - sudo mkdir -p $thatDir/backup - sudo cp $thatDir/Icons.plist $thatDir/backup/ + sudo mkdir -p $thatDir/HIDPI/backup + sudo cp $thatDir/Icons.plist $thatDir/HIDPI/backup/ if [[ -d $thatDir/DisplayVendorID-$Vid ]]; then - sudo cp -r $thatDir/DisplayVendorID-$Vid $thatDir/backup/ + sudo cp -r $thatDir/DisplayVendorID-$Vid $thatDir/HIDPI/backup/ fi fi + + if [[ ! -f $thatDir/HIDPI/disable ]]; then + generate_restore_cmd + fi +} + +# +function generate_restore_cmd() +{ +# +rm -rf $thisDir/tmp/ +mkdir -p $thisDir/tmp/ +cat > "$thisDir/tmp/disable" <<-\CCC +function get_edid() +{ + local index=0 + local selection=0 + + gDisplayInf=($(ioreg -lw0 | grep -i "IODisplayEDID" | sed -e "/[^<]*//")) + + if [[ "${#gDisplayInf[@]}" -ge 2 ]]; then + + echo ' Monitors ' + echo '------------------------------------' + echo ' Index | VendorID | ProductID ' + echo '------------------------------------' + + for display in "${gDisplayInf[@]}" + do + let index++ + printf " %d | ${display:16:4} | ${display:20:4}\n" $index + done + + echo '------------------------------------' + + read -p "Choose the display: " selection + case $selection in + [[:digit:]]* ) + if ((selection < 1 || selection > index)); then + echo "Enter error, bye"; + exit 0 + fi + let selection-=1 + gMonitor=${gDisplayInf[$selection]} + ;; + + * ) + echo "Enter error, bye"; + exit 0 + ;; + esac + else + gMonitor=${gDisplayInf} + 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 + Vid=$gDisplayVendorID_RAW + Pid=$gDisplayProductID_reverse + # echo $Vid + # echo $Pid + # echo $EDID +} + +get_edid + +if [[ -d ../DisplayVendorID-$Vid ]]; then + rm -rf ../DisplayVendorID-$Vid +fi + +rm -rf ../Icons.plist +cp -r ./backup/* ../ +rm -rf ./disable +echo "HIDPI Disabled" +CCC + +sudo mv $thisDir/tmp/disable $thatDir/HIDPI/ +sudo chmod +x $thatDir/HIDPI/disable + } # choose_icon @@ -185,21 +244,23 @@ EOF read -p "Enter your choice [1~5]: " logo case $logo in 1) Picon=$imacicon - RP=("33" "68" "160" "90") - ;; + RP=("33" "68" "160" "90") + ;; 2) Picon=$mbicon - RP=("52" "66" "122" "76") - ;; + RP=("52" "66" "122" "76") + ;; 3) Picon=$mbpicon - RP=("40" "62" "147" "92") - ;; + RP=("40" "62" "147" "92") + ;; 4) Picon=$lgicon - RP=("11" "47" "202" "114") - DICON=${Overrides}"DisplayVendorID-1e6d\/DisplayProductID-5b11.icns" - ;; + RP=("11" "47" "202" "114") + DICON=${Overrides}"DisplayVendorID-1e6d\/DisplayProductID-5b11.icns" + ;; 5) rm -rf $thisDir/tmp/Icons.plist - ;; - *) echo "Enter error, bye"; + ;; + *) + + echo "Enter error, bye"; exit 0 ;; esac @@ -252,19 +313,19 @@ EOF read -p "Enter your choice: " res case $res in - 1 ) create_res_1 1920x1080 1680x945 1440x810 1280x720 1024x576 + 1 ) create_res_1 1680x944 1600x900 1440x810 1280x720 1024x576 ;; - 2 ) create_res_1 2048x1152 1920x1080 1680x945 1440x810 1280x720 - create_res_2 1024x576 - create_res_3 960x540 - create_res_4 2048x1152 + 2 ) create_res_1 2048x1152 1920x1080 1680x944 1440x810 1280x720 + create_res_2 1024x576 + create_res_3 960x540 + create_res_4 2048x1152 1920x1080 ;; 3 ) custom_res;; - esac +esac -create_res_2 1280x720 960x540 640x360 -create_res_3 840x472 720x405 640x360 576x324 512x288 420x234 400x225 320x180 -create_res_4 1920x1080 1680x945 1440x810 1280x720 1024x576 960x540 640x360 +create_res_2 1280x800 1280x720 960x600 960x540 640x360 +create_res_3 840x472 800x450 720x405 640x360 576x324 512x288 420x234 400x225 320x180 +create_res_4 1680x944 1600x900 1440x810 1280x720 1024x576 960x540 840x472 800x450 640x360 cat >> "$dpiFile" <<-\FFF @@ -285,7 +346,6 @@ function end() sudo rm -rf $thisDir/tmp echo "Enabled, please reboot." echo "Rebooting the logo for the first time will become huge, then it will not be." - say "Good" } # custom resolution @@ -385,13 +445,17 @@ function enable_hidpi_with_patch() # disable function disable() { - sudo rm -rf $thatDir/DisplayVendorID-$Vid + if [[ -d $thatDir/DisplayVendorID-$Vid ]]; then + sudo rm -rf $thatDir/DisplayVendorID-$Vid + fi + sudo rm -rf $thatDir/Icons.plist - sudo cp -r $thatDir/backup/* $thatDir/ - sudo rm -rf $thatDir/backup + sudo cp -r $thatDir/HIDPI/backup/* $thatDir/ + sudo rm -rf $thatDir/HIDPI/disable echo "Disabled, restart takes effect" } +# function start() { init @@ -413,10 +477,11 @@ case $input in 3) disable ;; *) + echo "Enter error, bye"; exit 0 ;; - esac - } +esac +} start