Last active
September 23, 2021 15:46
-
-
Save donalod/7c0a63df318aff3739e72f7ad9ec3854 to your computer and use it in GitHub Desktop.
throttle.applescript
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
-- https://stackoverflow.com/questions/34876073/switch-network-link-conditioner-profiles-from-console-script/38991769 | |
-- found via https://gist.github.com/cantyjeffrey/42a0d080c83c46a6f76e5705fd6d90af | |
set mode to system attribute "mode" | |
tell application "System Preferences" | |
activate | |
set current pane to pane "com.apple.Network-Link-Conditioner" | |
delay 1 | |
end tell | |
tell application "System Events" | |
tell process "System Preferences" | |
if mode is equal to "OFF" | |
tell window "Network Link Conditioner" | |
click button "OFF" | |
end tell | |
else | |
tell window "Network Link Conditioner" | |
click button "ON" | |
tell group 1 | |
click pop up button 1 | |
click menu item mode of menu 1 of pop up button 1 | |
end tell | |
end tell | |
end if | |
end tell | |
end tell | |
# tell application "System Preferences" to quit | |
## Leaving the panel open above on demo machines so we don't forget!! | |
## Usage below but we will call from a bash script + from cron | |
## Set mode to 3G throttling... | |
# mode=3G osascript throttle.applescript | |
## Set mode to "Very Bad Network"... | |
# mode="Very Bad Network" osascript throttle.applescript | |
## Turn off throttling... | |
# mode=OFF osascript throttle.applescript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment