Last active
November 16, 2019 11:49
-
-
Save Coro365/1fb75d74c68a8a012c9f2a0acfeac74d to your computer and use it in GitHub Desktop.
This script iTunes(Music.app) play, pause, next track, back track and return state.
This file contains 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/sh | |
# @(#) This script Music.app play, pause, next track, back track and return state. | |
# @(#) Support macOS Catalina version.20191116 | |
if [ -z "$1" ]; then | |
echo "Argument is missing!" | |
exit 1 | |
elif [ "$1" == "play" ]; then | |
music_run=`osascript -e 'application "Music" is running'` | |
if [ "$music_run" == "false" ]; then | |
osascript -e 'tell application "Music" to activate' | |
fi | |
osascript -e 'tell application "Music" to play' | |
elif [ "$1" == "pause" ]; then | |
music_run=`osascript -e 'application "Music" is running'` | |
if [ "$music_run" == "true" ]; then | |
osascript -e 'tell application "Music" to pause' | |
fi | |
elif [ "$1" == "next" ]; then | |
osascript -e 'tell application "Music" to next track' | |
elif [ "$1" == "back" ]; then | |
osascript -e 'tell application "Music" to back track' | |
elif [ "$1" == "status" ]; then | |
osascript ./iTunes_status.scpt | |
else | |
echo "Invalid argument!" | |
exit 1 | |
fi |
This file contains 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
if application "Music" is running then | |
tell application "Music" | |
set a to player position as text | |
delay 1 | |
set b to player position as text | |
if a = b then | |
--log "status:pause" | |
return 0 | |
else | |
--log "status:play" | |
return 1 | |
end if | |
end tell | |
else | |
--log "Music.app not working" | |
return 0 | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment