Last active
October 7, 2022 03:26
-
-
Save MuntashirAkon/c9844c0c3095a4f28500b1d3115f0124 to your computer and use it in GitHub Desktop.
LittleSnitchToggler
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
#!/bin/bash | |
# | |
# LittleSnitchToggler | |
# Script to enable/disable Little Snitch | |
# (c) Muntashir Al-Islam | |
# License: MIT License | |
# | |
# Alert if not a root user | |
# | |
if ! [ `id -u` -eq 0 ]; then | |
echo "The script must be run as root!" | |
exit 1 | |
fi | |
daemon="/Library/LaunchDaemons/at.obdev.littlesnitchd.plist" | |
home=`echo ~` | |
wd="${home}/.ls" | |
agent_loc="/Library/LaunchAgents/" | |
helper="at.obdev.LittleSnitchHelper.plist" | |
ui_agent="at.obdev.LittleSnitchUIAgent.plist" | |
app_loc="/Library/Little Snitch" | |
function moveToWD(){ | |
sudo mv $agent_loc$helper "$wd" | |
sudo mv $agent_loc$ui_agent "$wd" | |
sudo mv "$app_loc"/* "$wd/" | |
# in case anything goes wrong | |
killall "Little Snitch Network Monitor" | |
} | |
function restore(){ | |
sudo mv "$wd/$helper" $agent_loc | |
sudo mv "$wd/$ui_agent" $agent_loc | |
sudo mv "$wd"/* "$app_loc/" | |
sleep 5 | |
open "$app_loc/Little Snitch Agent.app" | |
open "$app_loc/Little Snitch Helper.app" | |
} | |
if [ -e $daemon ]; then | |
sudo launchctl list | grep at.obdev.littlesnitchd > /dev/null 2>&1 | |
status=$? | |
# make working folder | |
mkdir "$wd" > /dev/null 2>&1 | |
if [ $status -eq 1 ]; then #disabled | |
#enable it | |
sudo launchctl load -w $daemon | |
restore | |
echo -e "ENABLED" | |
exit 0 | |
else | |
sudo launchctl unload -w $daemon | |
moveToWD | |
echo -e "DISABLED" | |
exit 0 | |
fi | |
else | |
echo -e "NOT FOUND"; | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The latest version of Little Snitch doesn't include any sort of disabler to disable it temporarily. This script can be used to do so.
My recommended way of installing this small tool:
and now make it executable:
Now, simply running
sudo togglelittlesnitch
will enable/disable Little Snitch.