Touchbar Lyric

参考官方文档:https://github.com/ChenghaoMou/touchbar-lyric

安装 python

安装过程不展开介绍了,可以使用brew、python.org官网、pyenv、conda等工具安装。

⚠️需要注意的问题:

  • 3.9.x、3.10.x版本会在控件中输出报错信息:
1
NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'
  • 解决方案:最终使用的是3.12.0

安装 touchbar_lyric

1
pip3 install touchbar_lyric --upgrade

测试 touchbar_lyric

1
python3 -m touchbar_lyric --app Music

在BetterTouchTool中配置

  1. 自定义菜单栏,选择Shell脚本 / 任务 widget

  1. 填写脚本配置:
  • 启动路径:/bin/bash
  • 参数:-c
  • 环境变量:在你本机的Terminal中输入echo $PATH,然后复制输出内容到此处,格式类似于:
    1
    PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin...

个性化(可选)

空白歌词显示「No Lyric」

1
2
3
4
5
6
output=$(python3 -m touchbar_lyric --app Music)
if [ -z "$output" ]; then
echo "No Lyric"
else
echo "$output"
fi