-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfvwm-menu-netcfg
executable file
·40 lines (33 loc) · 1.19 KB
/
fvwm-menu-netcfg
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
#!/bin/bash
# fvwm-menu-netcfg
# by greatant
# https://github.com/greatant/fvwm-pipemenus/
#
# Requires: netcfg
# fvwm-menu-netcfg-scan (wifi-pipe port: https://github.com/pbrisbin/wifi-pipe)
# Xdialog or zenity
# password-less sudo access to netcfg and fvwm-menu-netcfg-scan
#====================================================
dif() {
awk 'BEGIN{RS=ORS=" "}
{NR==FNR?a[$0]++:a[$0]--}
END{for(k in a)if(a[k])print k}' <(echo -n "${!1}") <(echo -n "${!2}")
}
ProfileDir="/etc/network.d/"
Active=( $(netcfg current) )
All=( $(netcfg list) )
Inactive=( $(dif All[@] Active[@]) )
echo "DestroyMenu recreate FvwmMenuNetcfg"
echo "AddToMenu FvwmMenuNetcfg \"Scan\" Popup FvwmMenuNetcfgScan"
if [ ${#Active[@]} -gt 0 ]; then
echo "AddToMenu FvwmMenuNetcfg \"Active profiles\" Title"
for profile in ${Active[@]}; do
. "${ProfileDir}${profile}"
echo "AddToMenu FvwmMenuNetcfg \"${profile} (${INTERFACE})%${CONNECTION}.png%\" Exec sudo netcfg down ${profile}"
done
fi
echo "AddToMenu FvwmMenuNetcfg \"Inactive profiles\" Title"
for profile in ${Inactive[@]}; do
. "${ProfileDir}${profile}"
echo "AddToMenu FvwmMenuNetcfg \"${profile}%${CONNECTION}.png%\" Exec sudo netcfg ${profile}"
done