-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdmenu-nm
More file actions
executable file
·40 lines (36 loc) · 993 Bytes
/
dmenu-nm
File metadata and controls
executable file
·40 lines (36 loc) · 993 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
35
36
37
38
39
40
#!/bin/bash
FONT="Monospace"
NORMAL_BACKGROUND="#000000"
NORMAL_FOREGROUND="#8f8f8f"
SELECTED_BACKGROUND="#000000"
SELECTED_FOREGROUND="#00ff00"
FLAGS=(
"-i"
"-b"
"-nb" "$NORMAL_BACKGROUND"
"-nf" "$NORMAL_FOREGROUND"
"-sb" "$SELECTED_BACKGROUND"
"-sf" "$SELECTED_FOREGROUND"
"-fn" "$FONT"
)
connect() {
SSID="$1"
notify-send --urgency=low "Attempting to connect to network: $SSID"
if nmcli device wifi connect "$SSID"; then
notify-send "Connected to network: $SSID"
exit 0
fi
if ERROR=$(
nmcli device wifi connect "$SSID" password "$(dmenu "${FLAGS[@]}" -p Password: </dev/null)"
); then
notify-send "Connected to network: $SSID"
else
notify-send --urgency=critical \
"Failed to connect to network: '$SSID' $ERROR"
fi
}
networks() {
nmcli --colors no --get-values ssid dev wifi list --rescan yes
}
SELECTION=$(networks | dmenu "${FLAGS[@]}") || exit 1
connect "$SELECTION"