From ca7ffc7800153af32f4715021a969456d3e5e0cd Mon Sep 17 00:00:00 2001 From: xzhih <842708096@qq.com> Date: Sun, 28 Oct 2018 00:37:34 +0800 Subject: [PATCH] Provide the sed's full absolute path, fix gnu-sed's issues #17. --- hidpi-zh.sh | 31 ++++++++++++++++++------------- hidpi.sh | 30 +++++++++++++++++++----------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/hidpi-zh.sh b/hidpi-zh.sh index 02e0357..f0ed3d1 100755 --- a/hidpi-zh.sh +++ b/hidpi-zh.sh @@ -13,6 +13,11 @@ cat << EEF | | | | _| |_ | |__| | | | _| |_ |_| |_| |_____| |_____/ |_| |_____| +============================================ + +注:由于我手头没有外置显示器做测试,如果你有多个显示器, +请在单显示器运行脚本,笔记本外接显示器时请盒盖 + ============================================ EEF # @@ -24,7 +29,7 @@ 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) + EDid=$(printf $edID | xxd -r -p | base64) thisDir=$(dirname $0) thatDir="/System/Library/Displays/Contents/Resources/Overrides" @@ -93,14 +98,14 @@ 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 + /usr/bin/sed -i "" "s/VID/$Vid/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/PID/$Pid/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/RPX/${RP[0]}/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/RPY/${RP[1]}/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/RPW/${RP[2]}/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/RPH/${RP[3]}/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/PICON/$Picon/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/DICON/$DICON/g" $thisDir/tmp/Icons.plist fi } @@ -162,8 +167,8 @@ cat >> "$dpiFile" <<-\FFF FFF - sed -i '' "s/VID/$VendorID/g" $dpiFile - sed -i '' "s/PID/$ProductID/g" $dpiFile + /usr/bin/sed -i "" "s/VID/$VendorID/g" $dpiFile + /usr/bin/sed -i "" "s/PID/$ProductID/g" $dpiFile } # 擦屁股 @@ -173,7 +178,7 @@ function end() sudo rm -rf $thisDir/tmp echo "开启成功,重启生效" echo "首次重启开机logo会变得巨大,之后就不会了" - say "妖怪,哪里跑" + # say "妖怪,哪里跑" } #自定义分辨率 @@ -266,7 +271,7 @@ function enable_hidpi_with_patch() { choose_icon main - sed -i '' "s:EDid:${EDid}:g" $dpiFile + /usr/bin/sed -i "" "s:EDid:${EDid}:g" $dpiFile end } diff --git a/hidpi.sh b/hidpi.sh index beee641..1ce2ad4 100755 --- a/hidpi.sh +++ b/hidpi.sh @@ -14,6 +14,14 @@ cat << EEF |_| |_| |_____| |_____/ |_| |_____| ============================================ + +Note: I don't have an external monitor to +test the script.If you have multiple monitors, +please run the script on a single monitor, +or cover the notebook when it is connected to the monitor. + +============================================ + EEF # VendorID=$(ioreg -l | grep "DisplayVendorID" | awk '{print $NF}') @@ -91,14 +99,14 @@ 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 + /usr/bin/sed -i "" "s/VID/$Vid/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/PID/$Pid/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/RPX/${RP[0]}/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/RPY/${RP[1]}/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/RPW/${RP[2]}/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/RPH/${RP[3]}/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/PICON/$Picon/g" $thisDir/tmp/Icons.plist + /usr/bin/sed -i "" "s/DICON/$DICON/g" $thisDir/tmp/Icons.plist fi } @@ -160,8 +168,8 @@ cat >> "$dpiFile" <<-\FFF FFF - sed -i '' "s/VID/$VendorID/g" $dpiFile - sed -i '' "s/PID/$ProductID/g" $dpiFile + /usr/bin/sed -i "" "s/VID/$VendorID/g" $dpiFile + /usr/bin/sed -i "" "s/PID/$ProductID/g" $dpiFile } # end @@ -264,7 +272,7 @@ function enable_hidpi_with_patch() { choose_icon main - sed -i '' "s:EDid:${EDid}:g" $dpiFile + /usr/bin/sed -i "" "s:EDid:${EDid}:g" $dpiFile end }