Swyx Desktop for macOS: Mute iTunes during phone calls
Hi All,
you like to listen to iTunes, but want the music to automagically stop during phone calls with Swyx Desktop?
Lucky you - Swyx Desktop has that nice scripting functionality to implement this by your own! :)
Here's how to do this:
Basic idea: Poll the status of Swyx Desktop. Additionally check if iTunes is running and playing a song. Now pause the music if a call starts (means user state is active) and continue playing music if the call ends.
Here's the source code of the appropriate Apple Script:
set swyxDesktopActive to 1
set iTunesActive to 1
set iTunesWasPlaying to false
set currentState to ""
set oldState to ""
repeat while swyxDesktopActive > 0
-- check if Swyx Desktop app and iTunes are running and end the repeat while loop, if Swyx Desktop is not running
tell application "System Events"
set swyxDesktopActive to count (every process whose displayed name is "Swyx Desktop")
set iTunesActive to count (every process whose displayed name is "iTunes")
end tell
if swyxDesktopActive > 0 then
tell application "Swyx Desktop"
set currentState to state
end tell
if currentState is equal to "active" then
if oldState is not equal to "active" then
-- default: iTunes is not playing
set iTunesWasPlaying to false
if iTunesActive > 0 then
-- iTunes is running, check if it is playing something
tell application "iTunes"
if player state is playing then
-- pause iTunes during active calls and store playing state
pause
set iTunesWasPlaying to true
end if
end tell
end if
end if
else
if oldState is equal to "active" then
if iTunesWasPlaying then
tell application "iTunes"
playpause
end tell
end if
end if
end if
set oldState to currentState
end if
-- wait a second
delay 1
end repeat
If you want to start the script from the terminal (or automatically) you can call it this way:
"osascript MyFancyScript.scpt"
And here's the link to download the script: Click
Enjoy :)
Stefan
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
0 Kommentare