-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshadowsocks_ui.sh
More file actions
executable file
·59 lines (53 loc) · 1.4 KB
/
shadowsocks_ui.sh
File metadata and controls
executable file
·59 lines (53 loc) · 1.4 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
BASE_NAME=$(basename "$0")
cd $1
LOCAL_HOST="'127.0.0.1'"
LOCAL_PORT="1080"
CONFIGS=config/configs
CURRENT_CONF=config/current_conf
function notificate {
config=$(cat $CURRENT_CONF)
echo "$1"
notify-send --app-icon shadowsocks \
--expire-time=5000 \
-h string:sound:false \
-h int:transient:5 \
-a "$BASE_NAME" "$1" "$config"
}
function ssservice_start {
config=$(cat $CURRENT_CONF)
ssservice local -c $config --daemonize &&
dconf write /system/proxy/mode "'manual'" &&
dconf write /system/proxy/socks/host $LOCAL_HOST &&
dconf write /system/proxy/socks/port $LOCAL_PORT &&
notificate "Proxy enabled"
}
function ssservice_kill {
pkill -f ssservice
if [[ $? != "1" ]]; then
dconf write /system/proxy/mode "'none'" &&
notificate "Proxy disabled"
else
ssservice_start
fi
}
function ssservice_restart {
pkill -f ssservice
ssservice_start
}
if [ "$2" == "--change-conf" ]; then
choise=$(zenity --list \
--title="Choose configuration" \
--height=400 \
--column="Cofiguration" $(find $CONFIGS -name "*.json" -printf "%f "))
if [ $? != "1" ]; then
echo "$choise" >$CURRENT_CONF
ssservice_restart
fi
else
if [ $(dconf read /system/proxy/mode) != "'manual'" ]; then
ssservice_start
else
ssservice_kill
fi
fi