Created
October 6, 2020 22:43
-
-
Save yerffejytnac/42a0d080c83c46a6f76e5705fd6d90af to your computer and use it in GitHub Desktop.
Use Network Link Conditioner from command line
This file contains hidden or 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 | |
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 |
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
Usage: