Skip to content

Instantly share code, notes, and snippets.

@yerffejytnac
Created October 6, 2020 22:43
Show Gist options
  • Save yerffejytnac/42a0d080c83c46a6f76e5705fd6d90af to your computer and use it in GitHub Desktop.
Save yerffejytnac/42a0d080c83c46a6f76e5705fd6d90af to your computer and use it in GitHub Desktop.
Use Network Link Conditioner from command line
-- https://stackoverflow.com/questions/34876073/switch-network-link-conditioner-profiles-from-console-script/38991769
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
-- http://apetronix.com/find-pane-id-for-system-preferences-app/
-- tell application "System Preferences"
-- set CurrentPane to the id of the current pane
-- set the clipboard to CurrentPane
-- display dialog "Current Pane ID: " & CurrentPane & return & return & "Pane ID has been copied to the clipboard."
-- end tell
@yerffejytnac
Copy link
Author

Usage:

# 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

@yerffejytnac
Copy link
Author

Add some aliases to your .zshrc file for convenience:

alias throttle:on="mode=3G osascript throttle.applescript"
alias throttle:off="mode=OFF osascript throttle.applescript"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment