如何根据Mac菜单栏浅色或深色更改Python菜单栏应用程序徽标黑白?

问题描述 投票:0回答:1

我想使用

rumps
包制作一个 Python 菜单栏应用程序,但我想让我的菜单栏徽标根据 Mac 菜单栏颜色从黑白变为黑色,有什么方法可以使用
rumps
来完成此操作?或者如果没有办法可以通过另一个Python包来实现吗?

Mac操作系统:12.0.1 Python:3.9.8

python macos menubar rumps
1个回答
0
投票

我不知道有哪个包可以动态读取/注册 macOS 主题更改,但您可以直接使用

defaults read -g AppleInterfaceStyle
:

查询活动主题
import subprocess

command = "defaults read -g AppleInterfaceStyle"
result = subprocess.run(command, shell=True, capture_output=True, text=True)

if result.stdout.rstrip() == "Dark":
    # Dark Mode
else:
    # Light Mode

此方法假设您的客户端具有访问系统信息和运行系统命令的适当权限。

© www.soinside.com 2019 - 2024. All rights reserved.