macbook 的 touchbar 功能在新版的 mac 上已经没了,但个人还是挺喜欢有 touchbar 的 mac 的。可以在 touchbar 上显示音乐歌词。
工具
- BetterTouchTool
- touchbar_lyric
- spotify
pip3 install touchbar_lyric --upgrade
去 touchbar_lyric 项目找到 lyric.json 文件,内容如下,导入到 BetterTouchTool 中。
[
{
"BTTWidgetName" : "Lyric",
"BTTTriggerType" : 642,
"BTTTriggerTypeDescription" : "Shell Script \/ Task Widget",
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : -1,
"BTTPredefinedActionName" : "No Action",
"BTTShellScriptWidgetGestureConfig" : "\/bin\/sh:::-c:::-:::",
"BTTEnabled2" : 1,
"BTTRepeatDelay" : 0,
"BTTUUID" : "93C8B565-73C7-49BE-960A-4FCF512CE881",
"BTTNotesInsteadOfDescription" : 0,
"BTTEnabled" : 1,
"BTTModifierMode" : 0,
"BTTOrder" : 0,
"BTTDisplayOrder" : 99,
"BTTMergeIntoTouchBarGroups" : 0,
"BTTTriggerConfig" : {
"BTTTouchBarFreeSpaceAfterButton" : 0,
"BTTTouchBarOnlyShowIcon" : false,
"BTTTouchBarButtonColor" : "0.000000, 0.000000, 0.000000, 255.000000",
"BTTTouchBarApplyCornerRadiusTo" : 0,
"BTTTouchBarItemPlacement" : 0,
"BTTTouchBarAppleScriptStringRunOnInit" : true,
"BTTTouchBarAlwaysShowButton" : false,
"BTTTouchBarFontColorAlternate" : "0.000000, 0.000000, 0.000000, 255.000000",
"BTTScriptType" : 0,
"BTTTouchBarButtonWidth" : 550,
"BTTTouchBarScriptUpdateInterval" : 1,
"BTTTouchBarItemIconHeight" : 22,
"BTTTouchBarButtonUseFixedWidth" : 0,
"BTTTouchBarButtonTextAlignment" : 1,
"BTTTouchBarAlternateBackgroundColor" : "0.000000, 0.000000, 0.000000, 255.000000",
"BTTTBWidgetWidth" : 400,
"BTTTouchBarItemIconWidth" : 22,
"BTTTouchBarShellScriptString" : "$PYTHONPATH -m touchbar_lyric --app Spotify",
"BTTTouchBarIconTextOffset" : 5,
"BTTTouchBarButtonFontSize" : 12,
"BTTTouchBarFontColor" : "156.000006, 226.000002, 90.000002, 255.000000",
"BTTTouchBarButtonName" : "Lyric",
"BTTTouchBarButtonCornerRadius" : 6,
"BTTTouchBarItemPadding" : 20
}
}
]
下载 lyric.json 文件,在 BetterTouchTool 中导入预设。
新建一个触发器,选择Shell脚本/任务 Widget
,小部件标识符写个名称,在下面4
中写入,/opt/homebrew/Cellar/[email protected]/3.9.19/bin/python3.9 -m touchbar_lyric --app Spotify --traditional
,这段脚本,在touchbar_lyric中可以找到。
如何判断 python3 的位置呢?
后续重启 BetterTouchTool 即可实现 touch bar 中显示歌词。