也不知道是不是T2的鍋, 2018款帶獨顯的MacBook有個問題, 啟動的時候要在設置-節能里切一下顯卡才能用雷電3的外接顯示器
最近買了顯示器, 這個問題就會比較煩人了, 所以就寫了下面這一段東西來添加一個服務, 自動切這個顯卡
下列腳本會在/Library/LaunchDaemons中添加一個叫local.fixGPUSwitch.startup.plist的文件, 目的是為了運行在/etc/中新添加的fixGPUSwitch.sh腳本, 如果不喜歡這兩個名字可以自己替換一下
先sudo -s輸入密碼切換到管理員模式
然后復制下面所有的內容粘貼就行了, 是不是懶到極致呢:
cd /Library/LaunchDaemons
sudo rm -rf local.fixGPUSwitch.startup.plist
sudo touch local.fixGPUSwitch.startup.plist
sudo cat >> local.fixGPUSwitch.startup.plist <<EOF
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.localhost.startup</string>
<key>Disabled</key>
<false/>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>LaunchOnlyOnce</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/etc/fixGPUSwitch.sh</string>
</array>
</dict>
</plist>
EOF
sudo launchctl load -w ./local.fixGPUSwitch.startup.plist
sudo rm -rf /etc/fixGPUSwitch.sh
sudo touch /etc/fixGPUSwitch.sh
sudo cat >> /etc/fixGPUSwitch.sh <<EOF
#!/bin/sh
sudo pmset -a GPUSwitch 1
ping -c 5 127.0.0.1
sudo pmset -a GPUSwitch 2
EOF
sudo chmod +x /etc/fixGPUSwitch.sh
exit