簡體   English   中英

以編程方式隱藏OSX電池菜單欄項

[英]Hiding OSX battery menu bar item programmatically

我很難找到一種禁用菜單欄上顯示系統電池圖標的方法。 我可以從系統偏好設置 - >節能器 - >“在菜單欄中顯示電池狀態”中禁用它,但有沒有辦法用終端defaults命令(或使用簡單的可可應用程序)實現相同的功能?

你可以使用終端中的默認方式來使用它,不要忘記使用killall SystemUIServer或重啟/注銷和登錄。

# Menu bar: hide the Time Machine, Volume, User and AirPort (WiFi) icons
for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do
defaults write "${domain}" dontAutoLoad -array \
    "/System/Library/CoreServices/Menu Extras/TimeMachine.menu" \
    "/System/Library/CoreServices/Menu Extras/Volume.menu" \
    "/System/Library/CoreServices/Menu Extras/User.menu" \
    "/System/Library/CoreServices/Menu Extras/AirPort.menu"
done
defaults write com.apple.systemuiserver menuExtras -array \
    "/System/Library/CoreServices/Menu Extras/Bluetooth.menu" \
    "/System/Library/CoreServices/Menu Extras/Battery.menu" \
    "/System/Library/CoreServices/Menu Extras/Clock.menu"
killall SystemUIServer

所以只需移動一次你想要隱藏在dontAutoLoad數組中的那些,以及你在menuExtras數組中看不到的那些。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM