Mac未适配暗黑模式临时方案

#未兼容Mac暗黑模式的应用 设置默认浅色
defaults write com.roadesign.Codyeapp NSRequiresAquaSystemAppearance true 
#读取Mac应用的bundleId
read /System/Applications/Shortcuts.app/Contents/Info.plist CFBundleIdentifier

#获取Mac应用bundleId  
osascript -e 'id of app "Xcode"' #获取Xcode

#设置全局深色模式显示浅色窗口 需重启电脑生效
#无论选择浅色还是深色,变化的只有菜单栏和 Dock 栏,窗口始终保持浅色 主要针对一些未适配暗黑模式的Mac应用
#一般来说info.plist默认强制浅色就好了的 默认的暗黑眼睛会看瞎~
defaults write -g NSRequiresAquaSystemAppearance -bool Yes  #[Dock 栏和菜单栏深色,其他浅色]
defaults delete -g NSRequiresAquaSystemAppearance  #清除设定

如果是全局一键切换的话可以使用Alfred 或者做成快捷指令通过菜单栏一键点击实现toggle

#!/bin/bash

query=$1

# Check=`defaults read -g AppleInterfaceStyle`

if [ "$query" = "dark" ]; then
	dark='true'
elif [ "$query" = "light" ]; then
	dark='false'
else
	dark='not dark mode'
fi

Script="tell app \"System Events\" to tell appearance preferences to set dark mode to $dark"

osascript -e "$Script"
posted @ 2024-01-17 22:37  CoderWGB  阅读(78)  评论(0)    收藏  举报