-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoggle_proxy
More file actions
executable file
·34 lines (31 loc) · 916 Bytes
/
toggle_proxy
File metadata and controls
executable file
·34 lines (31 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# You can change messages
connect='Proxy Connected'
disconnect='Proxy Disconnected'
messages=("${connect}" "${disconnect}")
tmpFile=~/.proxy_status # Temporary file to set the warp status inside it
touch "${tmpFile}" # Create it, if it's not existed yet
status=$(cat ${tmpFile}) # Read the file and store its value inside a variable
function notify {
if [ -x "$(command -v notify-send)" ]; then
notify-send "$1"
else
zenity --notification --text "$1"
fi
~/bin/say "${1}"
}
if [[ ${status} -eq 0 ]]; then
export http_proxy="socks5://127.0.0.1:8086"
export https_proxy="socks5://127.0.0.1:8086"
export all_proxy="socks5://127.0.0.1:8086"
export ALL_PROXY="socks5://127.0.0.1:8086"
notify "${messages[0]}"
echo 1 >"${tmpFile}"
else
unset -f http_proxy
unset -f https_proxy
unset -f all_proxy
unset -f ALL_PROXY
notify "${messages[1]}"
echo 0 >"${tmpFile}"
fi