lylehust
2023-06-01 14:31:21 +08:00
可以用 applescript 来控制 music ,暂停,下一曲等。然后再自己定义快捷键调用这些脚本就行。我用的是 hammerspoon 。
-------------------
Play_Pause:
#!/usr/bin/env osascript
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
if is_running("Music") then
tell application "Music"
playpause
end tell
else if is_running("Spotify") then
tell application "Spotify"
playpause
end tell
else if is_running("Cog") then
tell application "Cog"
pause
end tell
else
return
end if
-------------
Next:
#!/usr/bin/env osascript
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
if is_running("Music") then
tell application "Music"
if player state is paused then
return
end if
next track
end tell
else if is_running("Spotify") then
tell application "Spotify"
if player state is paused then
return
end if
next track
end tell
else if is_running("Cog") then
tell application "Cog"
next track
end tell
else
return
end if
--------------
Previous:
#!/usr/bin/env osascript
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
if is_running("Music") then
tell application "Music"
if player state is paused then
return
end if
previous track
end tell
else if is_running("Spotify") then
tell application "Spotify"
if player state is paused then
return
end if
previous track
end tell
else if is_running("Cog") then
tell application "Cog"
previous track
end tell
else
return
end if