Lock macOS Screen
activate application "SystemUIServer"
tell application "System Events"
tell process "SystemUIServer" to keystroke "q" using {command down, control down}
end tell
activate application "SystemUIServer"
tell application "System Events"
tell process "SystemUIServer" to keystroke "q" using {command down, control down}
end tell
tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preference.sidecar"
get the name of every anchor of pane id "com.apple.preference.sidecar"
delay 1
tell application "System Events"
set target_button to a reference to (first button whose name is "Disconnect") of (window "Sidecar" of application process "System Preferences")
if target_button exists then
click target_button
else
click menu button "Select Device" of window "Sidecar" of application process "System Preferences"
count menu items of menu of menu button "Select Device" of window "Sidecar" of application process "System Preferences"
select item 1 of menu button "Select Device" of window "Sidecar" of application process "System Preferences"
key code 125
key code 76
end if
end tell
quit
end tell
tell application "Music"
set shuffle enabled to true
play playlist "Music"
set song repeat to off
set sound volume of AirPlay device "Homepod" to 40
set sound volume of AirPlay device "HomePodMini" to 38
set volume output volume 42 with output muted --100%
set mainSpeaker to (first AirPlay device whose name = "Homepod")
set secondSpeaker to (first AirPlay device whose name = "HomePodMini")
set current AirPlay devices to {mainSpeaker, secondSpeaker}
end tell
tell application "Finder" to set volume 100
 You can listen free music radio from multi sound system such as bluetooh, HDMI and Airplay at the same moment. Please install third party macOS app "Airfoil" ( https://rogueamoeba.com/airfoil/mac/ ) and connect all your sound devices to your Mac through "Airfoil" then insert below script
tell application "Airfoil"
set pathToApp to (POSIX path of (path to application "Music"))
set newSource to make new application source
set application file of newSource to pathToApp
set (current audio source) to newSource
disconnect from every speaker
delay 3
connect to speaker "HomePod"
set (volume of speaker "HomePod") to 0.5
delay 3
connect to speaker "MyBluetoothSpeaker"
set (volume of speaker "MyBluetoothSpeaker") to 0.6
delay 3
connect to speaker "MyHDMISpeaker"
set (volume of speaker "MyHDMISpeaker") to 0.7
delay 3
end tell
tell application "Music"
set shuffle enabled to true
set song repeat to off
set sound volume of AirPlay device "MyMac" to 80
set volume output volume 20 with output muted --100%
set computerSpeaker to (first AirPlay device whose name = "MyMac")
set current AirPlay devices to {computerSpeaker}
end tell
set rNubmer to (random number from 1 to 16)
if rNubmer is equal to 1 then
tell application "Music" to open location "http://hearme.fm:9506/autodj"
end if
if rNubmer is equal to 2 then
tell application "Music" to open location "http://ekrrockradio5.scs.ms:8510/listen.pls"
end if
if rNubmer is equal to 3 then
tell application "Music" to open location "http://ais-edge51-live365-dal02.cdnstream.com/a44752"
end if
if rNubmer is equal to 4 then
tell application "Music" to open location "http://live.kvmr.org:8000/aac96"
end if
if rNubmer is equal to 5 then
tell application "Music" to open location "http://kcrw.streamguys1.com/kcrw_128k_aac_on_air_itunes"
end if
if rNubmer is equal to 6 then
tell application "Music" to open location "http://listen.shoutcast.com/a-arap"
end if
if rNubmer is equal to 7 then
tell application "Music" to open location "http://www.b-gyrl.com/radio/b-gyrlradio.m3u"
end if
if rNubmer is equal to 8 then
tell application "Music" to open location "http://streaming.radio.co/sb20285591/listen"
end if
if rNubmer is equal to 9 then
tell application "Music" to open location "http://www.my105.ch/my105thebattle.m3u"
end if
if rNubmer is equal to 10 then
tell application "Music" to open location "http://listen.christianrock.net/stream/3/"
end if
if rNubmer is equal to 11 then
tell application "Music" to open location "http://listen.shoutcast.com/a-ar-b"
end if
if rNubmer is equal to 12 then
tell application "Music" to open location "http://hearme.fm:8708/stream"
end if
if rNubmer is equal to 13 then
tell application "Music" to open location "http://stream.laut.fm/papa-mike.m3u"
end if
if rNubmer is equal to 14 then
tell application "Music" to open location "https://www.luxfunkradio.com/luxfunkdance.pls"
end if
if rNubmer is equal to 15 then
tell application "Music" to open location "http://stream.radiojar.com/milkchocolate.mp3"
end if
if rNubmer is equal to 16 then
tell application "Music" to open location "http://listen.113.fm/star.m3u"
end if
delay 5
tell application "System Events"
tell process "Music"
if title of window 1 is "MiniPlayer" then
else if title of window 1 is not "MiniPlayer" then
tell application "Music" to activate
keystroke "m" using {command down, shift down}
end if
end tell
end tell
on run
try
set airport_status to do shell script "networksetup -getairportpower en0"
on error
display dialog "The script did't work, please check the 'networksetup' command (in terminal) works on your system. " buttons {"OK"}
end try
if airport_status is "Wi-Fi Power (en0): On" then
do shell script "networksetup -setairportpower en0 off"
do shell script "networksetup -setairportpower en0 on"
display dialog "Wi-Fi restarted" giving up after 5
else if airport_status is "Wi-Fi Power (en0): Off" then
do shell script "networksetup -setairportpower en0 on"
display dialog "Wi-Fi started" giving up after 5
else
display dialog "The script did't work, please check the Wi-Fi interface name (e.g. en1) " buttons {"OK"}
end if
end run
@ 2022 | ballballg.com