-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathkde5.sh
79 lines (67 loc) · 2.43 KB
/
kde5.sh
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# plugin to set "KDE plasma 5" proxy settings for ProxyMan
# privileges has to be set by the process which starts this script
list_proxy() {
echo
echo "${bold}Desktop proxy settings (KDE) ${normal}"
mode=$(kreadconfig5 --file kioslaverc --group "Proxy Settings" --key ProxyType)
if [ "$mode" = "0" ]; then
echo "${red}None${normal}"
return
fi
echo "${bold} http ${normal} "\
"$(kreadconfig5 --file kioslaverc --group "Proxy Settings" --key httpProxy) "
echo "${bold} https ${normal} "\
"$(kreadconfig5 --file kioslaverc --group "Proxy Settings" --key httpsProxy) "
echo "${bold} ftp ${normal} "\
"$(kreadconfig5 --file kioslaverc --group "Proxy Settings" --key ftpProxy) "
echo "${bold} socks ${normal} "\
"$(kreadconfig5 --file kioslaverc --group "Proxy Settings" --key sockProxy) "
echo "${bold} no_proxy ${normal} "\
"$(kreadconfig5 --file kioslaverc --group "Proxy Settings" --key NoProxyFor) "
}
unset_proxy() {
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key ProxyType 0
}
set_proxy() {
# do quote the variables as blank variables mean nothing when not quoted and show errors
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key ProxyType 1
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key httpProxy "http://$http_host $http_port"
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key httpsProxy "http://$https_host $https_port"
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key ftpProxy "ftp://$ftp_host $ftp_port"
if [[ "$socks_host" != "" ]]; then
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key socksProxy "socks://$socks_host $socks_port"
else
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key socksProxy ""
fi
if [[ "$no_proxy" != "" ]]; then
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key NoProxyFor "$no_proxy"
else
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key NoProxyFor ""
fi
}
which kwriteconfig5 &> /dev/null
if [ "$?" != 0 ]; then
exit
fi
if [ "$#" = 0 ]; then
exit
fi
which kreadconfig5 &> /dev/null
if [ "$?" != 0 ]; then
exit
fi
if [ "$#" = 0 ]; then
exit
fi
what_to_do=$1
case $what_to_do in
set) set_proxy
;;
unset) unset_proxy
;;
list) list_proxy
;;
*)
;;
esac