名称: home-music
描述: 通过结合 Spotify 播放与 Airfoil 扬声器路由,控制全屋音乐场景。提供早晨、派对、放松等模式的快速预设。
主页: local
元数据: {"clawdbot":{"emoji":"🏠","os":["darwin"]}}
触发器:
- music scene
- morning music
- party mode
- chill music
- house music
- stop music
♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫
🏠 全 屋 音 乐 🎵
╔══════════════════════════════════════════╗
║ 全屋音乐场景 ║
║ 一个命令。所有扬声器。完美。 ║
╚══════════════════════════════════════════╝
♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫ ♪ ♫
"何必点击 17 次,一个命令就能搞定?" – Owen 🐸
全屋音乐 技能将 Spotify 与 Airfoil 结合,创造出神奇的音乐场景。只需一个命令,即可在合适的扬声器上以完美音量播放对应的歌单。
想象一下:
- 清晨醒来 → home-music morning → 浴室响起轻柔的音乐
- 朋友到访 → home-music party → 所有扬声器开始播放摇滚乐
- 放松时刻 → home-music chill → 舒缓的休息室氛围音乐遍布全屋
- 一天结束 → home-music off → 安静。平和。宁静。
| 项目 | 作用 | 链接 |
|---|---|---|
| 🍏 macOS | 本技能使用 AppleScript | — |
| 🟢 Spotify 桌面应用 | 音乐来源!必须处于运行状态。 | spotify.com |
| 📡 Airfoil | 将音频路由到 AirPlay 扬声器 | rogueamoeba.com |
| 🎵 spotify-applescript | 用于控制 Spotify 的 Clawdbot 技能 | skills/spotify-applescript/ |
⚠️ 重要提示: 在启动任何场景之前,Spotify 和 Airfoil 都必须处于运行状态!
开启温和的一天
home-music morning
是时候庆祝了!
home-music party
纯粹的放松
home-music chill
静音
home-music off
当前正在播放什么?
home-music status
显示:
- 当前 Spotify 播放的曲目
- 已连接的扬声器
# 使脚本可执行
chmod +x ~/clawd/skills/home-music/home-music.sh
# 创建符号链接以便全局访问
sudo ln -sf ~/clawd/skills/home-music/home-music.sh /usr/local/bin/home-music
现在,你可以在终端的任何位置使用 home-music 命令了!🎉
打开 home-music.sh 文件,找到歌单配置部分:
# === 歌单配置 ===
PLAYLIST_MORNING="spotify:playlist:19n65kQ5NEKgkvSAla5IF6"
PLAYLIST_PARTY="spotify:playlist:37i9dQZF1DXaXB8fQg7xif"
PLAYLIST_CHILL="spotify:playlist:37i9dQZF1DWTwnEm1IYyoj"
如何获取歌单 URI:
1. 在 Spotify 中右键点击歌单
2. 选择“分享” → “复制 Spotify URI”
3. 或者复制 URL 并提取 /playlist/ 后面的部分
在 main 代码块中添加新的 case:
# 在 home-music.sh 文件的 "scene_chill" 函数之后添加:
scene_workout() {
echo "💪 启动健身场景..."
airfoil_set_source_spotify
airfoil_connect "Sonos Move"
sleep 0.5
airfoil_volume "Sonos Move" 0.8
"$SPOTIFY_CMD" play "spotify:playlist:你的健身歌单URI"
"$SPOTIFY_CMD" volume 100
echo "✅ 健身模式:Sonos Move @ 80%,动起来!"
}
# 并在 case 代码块中添加:
workout)
scene_workout
;;
ALL_SPEAKERS=("Computer" "Andy's M5 Macbook" "Sonos Move" "Living Room TV")
你可以添加任何 AirPlay 扬声器——只要它们能在 Airfoil 中显示即可。
检查 1: Airfoil 是否在运行?
pgrep -x Airfoil || echo "Airfoil 未运行!"
检查 2: 扬声器是否在网络上?
- 打开 Airfoil 应用
- 检查扬声器是否出现在列表中
- 尝试手动连接
检查 3: 名称是否完全正确?
- 扬声器名称区分大小写!
- 打开 Airfoil 并复制确切的名称
检查 1: Spotify 是否在播放?
~/clawd/skills/spotify-applescript/spotify.sh status
检查 2: Airfoil 的音频源是否正确?
- 打开 Airfoil
- 检查是否选择了 "Spotify" 作为音频源
- 如果没有:点击“源” → 选择 Spotify
检查 3: 扬声器音量?
# 手动检查音量
osascript -e 'tell application "Airfoil" to get volume of (first speaker whose name is "Sonos Move")'
Spotify 是否已打开?
pgrep -x Spotify || open -a Spotify
spotify-applescript 是否已安装?
ls ~/clawd/skills/spotify-applescript/spotify.sh
chmod +x ~/clawd/skills/home-music/home-music.sh
如果你想手动控制 Airfoil:
# 连接扬声器
osascript -e 'tell application "Airfoil" to connect to (first speaker whose name is "Sonos Move")'
# 设置扬声器音量 (0.0 - 1.0)
osascript -e 'tell application "Airfoil" to set (volume of (first speaker whose name is "Sonos Move")) to 0.5'
# 断开扬声器连接
osascript -e 'tell application "Airfoil" to disconnect from (first speaker whose name is "Sonos Move")'
# 列出已连接的扬声器
osascript -e 'tell application "Airfoil" to get name of every speaker whose connected is true'
# 设置音频源
osascript -e 'tell application "Airfoil"
set theSource to (first application source whose name contains "Spotify")
set current audio source to theSource
end tell'
skills/home-music/
├── SKILL.md # 本文档
└── home-music.sh # 主脚本
设置别名以获得更快的访问速度:
bash
alias mm="home-music morning"
alias mp="home-music party"
alias mc="home-music chill"
alias mo="home-music off"
与 Clawdbot 配合使用:
> "嘿,启动派对模式"
> "播放一些放松的音乐"
> "停止播放音乐"
组合场景: 创建一个 dinner 场景,以 25% 的音量播放爵士乐歌单——非常适合招待客人!
╭─────────────────────────────────────────────╮
│ │
│ 由青蛙 Owen 用 💚 精心打造 🐸 │
│ │
│ "呱呱。音乐让一切变得更美好。" │
│ │
╰─────────────────────────────────────────────╯
作者: Andy Steinberger (在他的 Clawdbot 青蛙 Owen 🐸 的帮助下)
版本: 1.0.0
许可证: MIT
池塘: 那个有睡莲的池塘 🪷
这个技能改善了你的生活吗?Owen 喜欢苍蝇。🪰