Last active
April 17, 2024 21:55
-
-
Save scottj/bcd2cb7b34f230e51c71d5fbf53c6066 to your computer and use it in GitHub Desktop.
Search Music.app on macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
QUERY=$1 | |
# https://stackoverflow.com/a/246128/226502 | |
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | |
/usr/bin/osascript ${SCRIPT_DIR}/music-search.scpt "${QUERY}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run argv | |
set savedClipboard to the clipboard | |
set the clipboard to ({item 1 of argv} as text) | |
do shell script "open /System/Applications/Music.app" | |
tell application "Music" to activate | |
delay 1.25 | |
tell application "System Events" | |
keystroke "f" using command down | |
keystroke "a" using command down | |
keystroke "v" using command down | |
delay 2 | |
key code 36 | |
end tell | |
delay 2 | |
set the clipboard to savedClipboard | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment