#!/bin/sh check() { [ ! -z $(pidof tor) ] && echo "On" || echo "Off" } checkNotif() { [ ! -z $(pidof tor) ] && notify-send "Tor activated" || notify-send "Tor deactivated" } checkWeb() { tor="$(curl --socks5-hostname localhost:9050 -s https://check.torproject.org | grep -c "Congratulation")" [ $tor -eq 0 ] && notify-send "Tor deactivated" || notify-send "Tor activated" } toggle() { [ ! -z "$(pidof tor)" ] && $(sudo systemctl stop tor) || $(sudo systemctl start tor) } restartTor() { sudo systemctl restart tor && notify-send "Tor restarting" || notify-send "Tor failed to restart" } checkIP() { curl --socks5-hostname localhost:9050 -s https://check.torproject.org | grep "IP" | cut -d'>' -f3 | cut -d'<' -f1 } case "$1" in -t ) $(toggle) ;; -c ) checkWeb ;; -r ) restartTor ;; -n ) checkNotif ;; -l ) echo "$(pidof tor | wc -l)" ;; --check-ip ) checkIP ;; * ) check ;; esac