diff --git a/README-zh.md b/README-zh.md
new file mode 100644
index 0000000..4da10f5
--- /dev/null
+++ b/README-zh.md
@@ -0,0 +1,48 @@
+# 一键开启 macOS HiDPI
+
+## 说明
+
+[English](README.md) | [中文](README-zh.md)
+
+ 此脚本的目的是为中低分辨率的屏幕开启 HiDPI 选项,并且具有原生的 HiDPI 设置,不需要 RDM 软件即可在系统显示器设置中设置
+
+macOS 的 DPI 机制和 Windows 下不一样,比如 1080p 的屏幕在 Windows 下有 125%、150% 这样的缩放选项,而同样的屏幕在 macOS 下,缩放选项里只是单纯的调节分辨率,这就使得在默认分辨率下字体和UI看起来很小,降低分辨率又显得模糊
+
+同时,此脚本也可以通过注入修补后的 EDID 修复闪屏,或者睡眠唤醒后的闪屏问题,当然这个修复因人而异
+
+开机的第二阶段 logo 总是会稍微放大,因为分辨率是仿冒的
+
+设置:
+
+![设置](./img/preferences.jpg)
+
+## 使用方法
+
+在终端输入以下命令回车即可
+
+```
+$ 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 文件夹中的备份复制出来。
+
+具体命令如下:
+
+```
+$ 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/* ./
+```
+
+## 从以下得到启发
+
+https://www.tonymacx86.com/threads/solved-black-screen-with-gtx-1070-lg-ultrafine-5k-sierra-10-12-4.219872/page-4#post-1644805
+
+https://github.com/syscl/Enable-HiDPI-OSX
+
diff --git a/README.md b/README.md
index a741fde..db1bc46 100755
--- a/README.md
+++ b/README.md
@@ -1,38 +1,45 @@
-# 一键开启MacOS HIDPI
+# Enable macOS HiDPI
-### 说明
+## Explanation
-此脚本的目的是为中低分辨率的屏幕开启 HIDPI 选项,并且具有原生的 HIDPI 设置,不需要 RDM 软件即可在系统显示器设置中设置
+[English](README.md) | [中文](README-zh.md)
-MacOS 的 dpi 机制和 win 下不一样,比如 1080p 的屏幕在 win 下有 125%、150% 这样的缩放选项,而同样的屏幕在 MacOS 下,缩放选项里只是单纯的调节分辨率,这就使得在默认分辨率下字体和UI看起来很小,降低分辨率又显得模糊。
+ This script can simulate macOS HiDPI on a non-retina display, and have a "Native" Scaled in System Preferences.
-同时,此脚本也可以通过注入修补后的 EDID 修复闪屏,或者睡眠唤醒后的闪屏问题,当然这个修复因人而异
+Some device have wake-up issue, script's second option may help, it inject a patched EDID, but another problem may exists here.
-效果:
+Logo scaling up may not be resolved, cuz the higher resolution is faked.
-![HIDPI效果.png](https://i.loli.net/2017/10/26/59f199e85deb7.png)
+System Preferences
-### 使用方法
+![Preferences](./img/preferences.jpg)
-在终端输入以下命令回车即可
+## Usage
+
+Run script in Terminal
```
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/xzhih/one-key-hidpi/master/hidpi.sh)"
```
-![运行](https://i.loli.net/2018/04/03/5ac2963c7b26b.png)
+![RUN](./img/run.jpg)
-### 恢复
+## Recovery
-如果使用此脚本后,开机无法进入系统,请到恢复模式中,使用终端删除 `/System/Library/Displays/Contents/Resources/Overrides` 下删除显示器VendorID对应的文件夹,并把backup文件夹中的备份复制出来。
+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
+
+In Terminal:
-具体命令如下:
```
-$ cd /Volumes/你的系统盘/System/Library/Displays/Contents/Resources/Overrides
+$ 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/* ./
```
+## Inspired
+https://www.tonymacx86.com/threads/solved-black-screen-with-gtx-1070-lg-ultrafine-5k-sierra-10-12-4.219872/page-4#post-1644805
+
+https://github.com/syscl/Enable-HiDPI-OSX
diff --git a/hidpi-zh.sh b/hidpi-zh.sh
new file mode 100755
index 0000000..2ad8565
--- /dev/null
+++ b/hidpi-zh.sh
@@ -0,0 +1,256 @@
+#!/bin/sh
+#
+# 初始化
+function init()
+{
+#
+cat << EEF
+
+ _ _ _____ _____ _____ _____
+ | | | | |_ _| | __ \ | __ \ |_ _|
+ | |__| | | | | | | | | |__) | | |
+ | __ | | | | | | | | ___/ | |
+ | | | | _| |_ | |__| | | | _| |_
+ |_| |_| |_____| |_____/ |_| |_____|
+
+============================================
+EEF
+ #
+ VendorID=$(ioreg -l | grep "DisplayVendorID" | awk '{print $8}')
+ ProductID=$(ioreg -l | grep "DisplayProductID" | awk '{print $8}')
+ EDID=$(ioreg -l | grep "IODisplayEDID" | awk '{print $8}' | sed -e 's/.$//' -e 's/^.//')
+
+ 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)
+
+ thisDir=$(dirname $0)
+ thatDir="/System/Library/Displays/Contents/Resources/Overrides"
+ Overrides="\/System\/Library\/Displays\/Contents\/Resources\/Overrides\/"
+
+ DICON="com\.apple\.cinema-display"
+ imacicon=${Overrides}"DisplayVendorID-610\/DisplayProductID-a032.tiff"
+ mbpicon=${Overrides}"DisplayVendorID-610\/DisplayProductID-a030-e1e1df.tiff"
+ mbicon=${Overrides}"DisplayVendorID-610\/DisplayProductID-a028-9d9da0.tiff"
+ lgicon=${Overrides}"DisplayVendorID-1e6d\/DisplayProductID-5b11.tiff"
+
+ if [[ ! -d $thatDir/backup ]]; then
+ echo "正在备份"
+ sudo mkdir -p $thatDir/backup
+ sudo cp $thatDir/Icons.plist $thatDir/backup/
+ if [[ -d $thatDir/DisplayVendorID-$Vid ]]; then
+ sudo cp -r $thatDir/DisplayVendorID-$Vid $thatDir/backup/
+ fi
+ fi
+}
+
+# 选择ICON
+function choose_icon()
+{
+ #
+ rm -rf $thisDir/tmp/
+ mkdir -p $thisDir/tmp/
+ curl -fsSL https://raw.githubusercontent.com/xzhih/one-key-hidpi/master/Icons.plist -o $thisDir/tmp/Icons.plist
+ # curl -fsSL http://127.0.0.1:8080/Icons.plist -o $thisDir/tmp/Icons.plist
+
+#
+cat << EOF
+----------------------------------------
+|********** 选择要显示的ICON ***********|
+----------------------------------------
+(1) iMac
+(2) MacBook
+(3) MacBook Pro
+(4) LG 显示器
+(5) 保持原样
+
+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
+;;
+esac
+
+if [[ $Picon ]]; then
+ sed -i '' "s/VID/$Vid/g" $thisDir/tmp/Icons.plist
+ sed -i '' "s/PID/$Pid/g" $thisDir/tmp/Icons.plist
+ sed -i '' "s/RPX/${RP[0]}/g" $thisDir/tmp/Icons.plist
+ sed -i '' "s/RPY/${RP[1]}/g" $thisDir/tmp/Icons.plist
+ sed -i '' "s/RPW/${RP[2]}/g" $thisDir/tmp/Icons.plist
+ sed -i '' "s/RPH/${RP[3]}/g" $thisDir/tmp/Icons.plist
+ sed -i '' "s/PICON/$Picon/g" $thisDir/tmp/Icons.plist
+ sed -i '' "s/DICON/$DICON/g" $thisDir/tmp/Icons.plist
+fi
+
+}
+
+# 主函数
+function main()
+{
+ sudo mkdir -p $thisDir/tmp/DisplayVendorID-$Vid
+ dpiFile=$thisDir/tmp/DisplayVendorID-$Vid/DisplayProductID-$Pid
+ sudo chmod -R 777 $thisDir/tmp/
+
+#
+cat > "$dpiFile" <<-\CCC
+
+
+
+
+ DisplayProductID
+ PID
+ DisplayVendorID
+ VID
+ IODisplayEDID
+ EDid
+ scale-resolutions
+
+CCC
+
+cat << EOF
+--------------------------------------
+|********** 选择分辨率配置 ***********|
+--------------------------------------
+(1) 1080P 显示屏
+(2) 2K 显示屏
+(3) 手动输入分辨率
+
+EOF
+
+read -p "选择你想要的配置: " res
+case $res in
+ 1 ) create_res 1680x945 1600x900 1440x810;;
+2 ) create_res 2048x1152 1920x1080 1840x1035 1760x990;;
+3 ) custom_res;;
+esac
+
+create_res 1280x720 1024x576 960x540 640x360
+
+cat >> "$dpiFile" <<-\FFF
+
+ target-default-ppmm
+ 10.0699301
+
+
+FFF
+
+ sed -i '' "s/VID/$VendorID/g" $dpiFile
+ sed -i '' "s/PID/$ProductID/g" $dpiFile
+}
+
+# 擦屁股
+function end()
+{
+ sudo cp -r $thisDir/tmp/* $thatDir/
+ sudo rm -rf $thisDir/tmp
+ echo "开启成功,重启生效"
+ echo "首次重启开机logo会变得巨大,之后就不会了"
+ say "妖怪,哪里跑"
+}
+
+#自定义分辨率
+function custom_res()
+{
+ echo "输入想要开启的 HIDPI 分辨率,用空格隔开,就像这样:1680x945 1600x900 1440x810"
+ read -p ":" res
+ create_res $res
+}
+
+# 创建分辨率配置
+function create_res()
+{
+ for res in $@; do
+ 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
+
+ ${hidpi:0:11}A
+ ${hidpi:0:11}AAAABACAAAA==
+ ${hidpi:0:11}AAAAJAKAAAA==
+
+OOO
+
+done
+}
+
+# 开
+function enable_hidpi()
+{
+ choose_icon
+ main
+ sed -i "" "/.*IODisplayEDID/d" $dpiFile
+ sed -i "" "/.*EDid/d" $dpiFile
+ end
+}
+
+# 开挂
+function enable_hidpi_with_patch()
+{
+ choose_icon
+ main
+ sed -i '' "s:EDid:${EDid}:g" $dpiFile
+ end
+}
+
+# 关
+function disable()
+{
+ sudo rm -rf $thatDir/DisplayVendorID-$Vid
+ sudo rm -rf $thatDir/Icons.plist
+ sudo cp -r $thatDir/backup/* $thatDir/
+ sudo rm -rf $thatDir/backup
+ echo "已关闭,重启生效"
+}
+
+function start()
+{
+ init
+#
+cat << EOF
+
+(1) 开启HIDPI
+(2) 开启HIDPI(同时注入花屏补丁)
+(3) 关闭HIDPI
+
+EOF
+
+read -p "输入你的选择[1~3]: " input
+case $input in
+ 1) enable_hidpi
+;;
+2) enable_hidpi_with_patch
+;;
+3) disable
+;;
+*)
+
+echo "输入错误,拜拜";
+exit 0
+;;
+esac
+}
+
+start
diff --git a/hidpi.sh b/hidpi.sh
index e12a315..0a2a388 100755
--- a/hidpi.sh
+++ b/hidpi.sh
@@ -1,13 +1,19 @@
#!/bin/sh
#
-# 初始化
+# init
function init()
{
#
cat << EEF
-----------------------------------------
-|*************** HIDPI ****************|
-----------------------------------------
+
+ _ _ _____ _____ _____ _____
+ | | | | |_ _| | __ \ | __ \ |_ _|
+ | |__| | | | | | | | | |__) | | |
+ | __ | | | | | | | | ___/ | |
+ | | | | _| |_ | |__| | | | _| |_
+ |_| |_| |_____| |_____/ |_| |_____|
+
+============================================
EEF
#
VendorID=$(ioreg -l | grep "DisplayVendorID" | awk '{print $8}')
@@ -18,25 +24,20 @@ EEF
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)
+
thisDir=$(dirname $0)
thatDir="/System/Library/Displays/Contents/Resources/Overrides"
-
Overrides="\/System\/Library\/Displays\/Contents\/Resources\/Overrides\/"
DICON="com\.apple\.cinema-display"
-
imacicon=${Overrides}"DisplayVendorID-610\/DisplayProductID-a032.tiff"
-
mbpicon=${Overrides}"DisplayVendorID-610\/DisplayProductID-a030-e1e1df.tiff"
-
mbicon=${Overrides}"DisplayVendorID-610\/DisplayProductID-a028-9d9da0.tiff"
-
lgicon=${Overrides}"DisplayVendorID-1e6d\/DisplayProductID-5b11.tiff"
if [[ ! -d $thatDir/backup ]]; then
- echo "正在备份"
+ echo "Backing up..."
sudo mkdir -p $thatDir/backup
sudo cp $thatDir/Icons.plist $thatDir/backup/
if [[ -d $thatDir/DisplayVendorID-$Vid ]]; then
@@ -45,7 +46,7 @@ EEF
fi
}
-# 选择ICON
+# choose_icon
function choose_icon()
{
#
@@ -56,18 +57,18 @@ function choose_icon()
#
cat << EOF
-----------------------------------------
-|********** 选择要显示的ICON ***********|
-----------------------------------------
+------------------------------------
+|********** Choose Icon ***********|
+------------------------------------
(1) iMac
(2) MacBook
(3) MacBook Pro
-(4) LG 显示器
-(5) 保持原样
+(4) LG Display
+(5) Remain as it is
EOF
-read -p "输入你的选择[1~5]: " logo
+read -p "Enter your choice [1~5]: " logo
case $logo in
1) Picon=$imacicon
RP=("33" "68" "160" "90")
@@ -84,9 +85,7 @@ DICON=${Overrides}"DisplayVendorID-1e6d\/DisplayProductID-5b11.icns"
;;
5) rm -rf $thisDir/tmp/Icons.plist
;;
-*)
-
-echo "输入错误,拜拜";
+*) echo "Enter error, bye";
exit 0
;;
esac
@@ -104,7 +103,7 @@ fi
}
-# 主函数
+# mian
function main()
{
sudo mkdir -p $thisDir/tmp/DisplayVendorID-$Vid
@@ -112,7 +111,7 @@ function main()
sudo chmod -R 777 $thisDir/tmp/
#
-cat > "$dpiFile" <<-\HIDPI
+cat > "$dpiFile" <<-\CCC
@@ -125,73 +124,77 @@ cat > "$dpiFile" <<-\HIDPI
EDid
scale-resolutions
-
-
-
-
+CCC
-
-
-
-
+cat << EOF
+------------------------------------------
+|********** resolution config ***********|
+------------------------------------------
+(1) 1080P Display
+(2) 2K Display
+(3) Manual input resolution
-
- AAANIAAAB2IA
- AAANIAAAB2IAAAABACAAAA==
- AAANIAAAB2IAAAAJAKAAAA==
+EOF
-
- AAALQAAABlQA
- AAALQAAABlQAAAABACAAAA==
- AAALQAAABlQAAAAJAKAAAA==
+read -p "Enter your choice: " res
+case $res in
+ 1 ) create_res 1680x945 1600x900 1440x810;;
+2 ) create_res 2048x1152 1920x1080 1840x1035 1760x990;;
+3 ) custom_res;;
+esac
-
- AAAKAAAABaAA
- AAAKAAAABaAAAAABACAAAA==
- AAAKAAAABaAAAAAJAKAAAA==
+create_res 1280x720 1024x576 960x540 640x360
-
- AAAIAAAABIAA
- AAAIAAAABIAAAAABACAAAA==
- AAAIAAAABIAAAAAJAKAAAA==
-
-
- AAAHgAAABDgA
- AAAHgAAABDgAAAABACAAAA==
- AAAHgAAABDgAAAAJAKAAAA==
-
-
- AAAFAAAAAWgA
- AAAFAAAAAWgAAAABACAAAA==
- AAAFAAAAAWgAAAAJAKAAAA==
-
+cat >> "$dpiFile" <<-\FFF
+
target-default-ppmm
10.0699301
-HIDPI
+FFF
sed -i '' "s/VID/$VendorID/g" $dpiFile
sed -i '' "s/PID/$ProductID/g" $dpiFile
}
-# 擦屁股
+# end
function end()
{
sudo cp -r $thisDir/tmp/* $thatDir/
sudo rm -rf $thisDir/tmp
- echo "开启成功,重启生效"
- echo "首次重启开机logo会变得巨大,之后就不会了"
- say "妖怪,哪里跑"
+ echo "Enabled, please reboot."
+ echo "Rebooting the logo for the first time will become huge, then it will not be."
+ say "Good"
}
-#自定义分辨率
-#hi = $(printf '%08x %08x' $((1920*2)) $((1080*2)))
-#encode_hi = $(echo $hi | xxd -r -p | base64)
+# custom resolution
+function custom_res()
+{
+ echo "Enter the HIDPI resolution, separated by a space,like this: 1680x945 1600x900 1440x810"
+ read -p ":" res
+ create_res $res
+}
+# create resolution
+function create_res()
+{
+ for res in $@; do
+ 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
+
+ ${hidpi:0:11}A
+ ${hidpi:0:11}AAAABACAAAA==
+ ${hidpi:0:11}AAAAJAKAAAA==
+OOO
-# 开
+done
+}
+
+# enable
function enable_hidpi()
{
choose_icon
@@ -201,7 +204,7 @@ function enable_hidpi()
end
}
-# 开挂
+# patch
function enable_hidpi_with_patch()
{
choose_icon
@@ -210,17 +213,14 @@ function enable_hidpi_with_patch()
end
}
-# 关
+# disable
function disable()
{
sudo rm -rf $thatDir/DisplayVendorID-$Vid
sudo rm -rf $thatDir/Icons.plist
-
sudo cp -r $thatDir/backup/* $thatDir/
-
sudo rm -rf $thatDir/backup
-
- echo "已关闭,重启生效"
+ echo "Disabled, restart takes effect"
}
function start()
@@ -229,13 +229,13 @@ function start()
#
cat << EOF
-(1) 开启HIDPI
-(2) 开启HIDPI(同时注入花屏补丁)
-(3) 关闭HIDPI
+(1) Enable HIDPI
+(2) Enable HIDPI (with patch)
+(3) Disable HIDPI
EOF
-read -p "输入你的选择[1~3]: " input
+read -p "Enter your choice [1~3]: " input
case $input in
1) enable_hidpi
;;
@@ -244,8 +244,7 @@ case $input in
3) disable
;;
*)
-
-echo "输入错误,拜拜";
+echo "Enter error, bye";
exit 0
;;
esac
diff --git a/img/preferences.jpg b/img/preferences.jpg
new file mode 100644
index 0000000..6729c11
Binary files /dev/null and b/img/preferences.jpg differ
diff --git a/img/run-zh.jpg b/img/run-zh.jpg
new file mode 100644
index 0000000..703dd79
Binary files /dev/null and b/img/run-zh.jpg differ
diff --git a/img/run.jpg b/img/run.jpg
new file mode 100644
index 0000000..8535487
Binary files /dev/null and b/img/run.jpg differ