Mac Dock Management
Hiding icons from dock while keeping the application open.
随着运行程序增多,Dock 会显示所有运行的程序图标。对于一些不常用的程序,可能会希望将其从 Dock 中移除,但又不想完全退出程序。本文介绍如何通过修改应用程序的 Info.plist 文件来隐藏 Dock 中的图标。
此方法适用于某些在菜单栏中显示的应用程序,如微信、QQ 等。通过这种方式,可以将这些应用程序的图标从 Dock 中移除,但仍然可以通过菜单栏访问它们。
将微信图标从 Dock 中移除
主要步骤如下:
备份 plist 文件 → 修改 plist 文件 → codesign 签名 → 重启应用程序
Caveat: 许多应用程序可能不允许修改 Info.plist 文件,或者修改后会影响应用程序的功能。需谨慎操作。建议修改之前备份原始的 Info.plist 文件,以防修改后出现问题。
以微信为例,将微信图标从 Dock 中移除,详细步骤如下:
-
最先需要备份对应的 Info.plist 文件
# 备份对应的Info.plist cp xxxx/Info.plist ~/Desktop/Info.plist
此步骤是为了防止修改后出现问题,可以随时恢复原来的状态。
若不想用命令行,可以直接在 Finder 中找到微信应用程序,右键点击“显示包内容”,然后找到
Contents
文件夹中的Info.plist
文件,将其复制到桌面或其他安全位置。 -
用 Vim 辑器打开对应 APP 的 Info.plist 文件
sudo vim /Applications/WeChat.app/Contents/Info.plist
输入密码。
-
修改 Info.plist 文件,添加以下内容
<key>LSUIElement</key> <true/>
最终的 Info.plist 文件内容如下所示:
保存 Info.plist 文件并退出。
-
codesign 重新签名
sudo codesign -f -s - "/Applications/WeChat.app"
输入密码。
-
重启 app,微信图标就会从 Dock 中消失。可以从菜单栏中打开微信。
Q: 如何重新在 Dock 显示图标?
A: 只需要删除 Info.plist 中与 LSUIElement
键相关的两行代码并 codesign 重新签名即可。
Q: 可以隐藏 Mac OS 系统应用吗?
A: 我尝试过修改 Stickies 的 Info.plist 文件,添加
LSUIElement
键,但并没有成功。可能是因为系统应用的权限更高,或者有其他限制。
Other tips
Other tips to organize Dock, making it less cluttered:
The idea is to keep only the running apps in the Dock. If you can disable an app from showing in the Dock while keeping it running, configure that, such as for WeChat. But such settings are not available for all apps.
Users might not have the necessary file permission (Read & Write) to modify the Info.plist file. Or, the setting will interfere with the app’s functionality. It is not worth it then.
Things you can try to keep the Dock clean:
- Settings → Desktop & Dock → Turn off “Show suggested and recent apps in Dock”.
- Remove unused apps from Dock and use Spotlight / Alfred to launch them when needed.
-
Use VS Code SCM (Source Code Management) tools to manage git repositories instead of using GitHub Desktop.
This way, one app fewer hogging the Dock.
cDock
https://github.com/w0lfschild/cDock?tab=readme-ov-file
Many reviews say cDock is buggy…
- cDock requires disabling System Integrity Protection
ref: