Last active
January 13, 2023 01:25
-
-
Save mazbox/4fde165eab9c7ae2368381c2d0988cce to your computer and use it in GitHub Desktop.
play/pause Music.app on Mac when running
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/zsh | |
musicAppOpen=`osascript -e 'tell application "System Events" to (name of processes) contains "Music"'` | |
rm -f "/tmp/xcode-itunes.txt" | |
if [ $musicAppOpen = 'true' ]; then | |
musicState=`osascript -e 'tell application "Music" to player state as string'` | |
if [ $musicState = 'playing' ]; then | |
echo 'play' > '/tmp/xcode-itunes.txt' | |
osascript -e 'tell application "Music" to pause' | |
fi | |
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
#!/bin/zsh | |
musicAppOpen=`osascript -e 'tell application "System Events" to (name of processes) contains "Music"'` | |
if [[ $musicAppOpen = 'true' && -f "/tmp/xcode-itunes.txt" ]]; | |
then | |
osascript -e 'tell application "Music" to play' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple shell scripts for pausing your music if playing when running app from Xcode, and unpausing when app finishes running.
If Music.app isn't open or you're not playing any music, the scripts won't attempt to unpause.
INSTALLATION
~/bin
andchmod +x
them.the first time you run it, you will have to allow it permission but after that you're golden.