禁用 Chrome 的黑色模式/Dark Mode

macOS Mojave 中引入了系统层面的黑色模式,Chrome 73 在应用中支行了这一模式,即系统设置为黑色模式时,Chrome 会自动适应切换到 Dark Mode。

Chrome 跟随系统设置的黑色模式 chrome-system-dark.png 不得不说,深色模式总是很受欢迎~

但其实黑色模式下标题与顶部系统菜单融为一体,且黑色模式下 Chrome 标签上内容辨识度也不高了,看起来还是有点别扭。更重要的是,主题没选好,可能就会导致如下图的情况咯(上面是chrome开启深色模式,下面是关闭深色模式。) Chrome 黑色模式下与普通模式的对比 chrome-diff.png 很明显,不开深色模式更舒服(可能chrome的主题有关系,大家自己去尝试)~ 所以决定系统使用 Dark Mode 的情况下将 Chrome 的黑色禁用。

通过命令行中设置 defaults 值可达到目的。

$ defaults write com.google.Chrome NSRequiresAquaSystemAppearance -bool Yes

如果想恢复默认,只需要将刚才设置的值删掉或者将 Yes 设置成 No。

$ defaults delete com.google.Chrome NSRequiresAquaSystemAppearance

禁用任意 App 的 Dark Mode

推而广之,不仅可禁止 Chrome 进入 Dark Mode,还可让其他任意 App 不进入 Dark Mode,如果该应用支持过 Dark Mode 的话。只需要找出该应用的打包发布的 bundle id 即可。这个 id 可通过下面的命令来得到。比如查看 Canary 版本的 Chrome:

$ osascript -e 'id of app "Google Chrome Canary"' 
com.google.Chrome.canary

其中 Google Chrome Canary (不区分大小写)是你在程序文件夹下看到的 .app 后缀的那个文件的文件名,比如这里 Google Chrome Canary.app。得到的 id 为 com.google.Chrome.canary 再代入最上面的命令中即可。

$ defaults write com.google.Chrome.canary NSRequiresAquaSystemAppearance -bool Yes

这里 id 是区分大小写的,写错不生效。

要恢复默认时同理。

其他默认值

通过 defaults read 可查看到所有应用已经存在的的 defaults 值。

$ defaults read >> defaults.txt

打开 defaults.txt 后搜索相应 app 的 id 可看到其所有可用值的列表。比如搜索 com.google.chrome

{
      "com.google.Chrome" =     {
        KeychainReauthorizeInAppSpring2017 = 2;
        KeychainReauthorizeInAppSpring2017Success = 1;
        LastRunAppBundlePath = "/Applications/Google Chrome.app";
        ...
    };
    "com.google.Chrome.canary" =     {
        KeychainReauthorizeInAppSpring2017 = 1;
        KeychainReauthorizeInAppSpring2017Success = 1;
        LastRunAppBundlePath = "/Applications/Google Chrome Canary.app";
        ...
    };
}

本文转载Wayou

WRITTEN BY:    Suremotoo

简约而不简单