fix empty key, add progressbar

This commit is contained in:
Tobias Powalowski 2023-08-31 09:31:34 +02:00
parent b2c91c09c0
commit 6d32cf5f30

View file

@ -24,6 +24,18 @@ _net_interfaces() {
find /sys/class/net/* -type l ! -name 'lo' -printf '%f ' -exec cat {}/address \;
}
_essid_scan() {
iwctl station "${_INTERFACE}" scan &>"${_NO_LOG}"
_COUNT=0
while true; do
sleep 1
_COUNT=$((_COUNT+1))
# abort after 5 seconds
_progress "$((_COUNT*5))" "Scanning $((5-_COUNT)) second(s) for SSIDs with interface ${_INTERFACE}..."
[[ "${_COUNT}" == 5 ]] && break
done
}
_essid_list() {
# only show lines with signal '*'
# kill spaces from the end and replace spaces with + between
@ -48,9 +60,7 @@ _wireless() {
_CONTINUE=""
while [[ -z "${_CONTINUE}" ]]; do
# scan the area
_dialog --title " Network Configuration " --no-mouse --infobox "Scanning for SSIDs with interface ${_INTERFACE}..." 3 60
iwctl station "${_INTERFACE}" scan &>"${_NO_LOG}"
sleep 5
_essid_scan | _dialog --title " Network Configuration " --no-mouse --gauge "Scanning 5 second(s) for SSIDs with interface ${_INTERFACE}..." 3 60
#shellcheck disable=SC2086,SC2046
if _dialog --cancel-label "${_LABEL}" --title " SSID Scan Result " --menu "Empty spaces in your SSID are replaced by '+' char" 13 60 6 \
"RESCAN" "SSIDs" "HIDDEN" "SSID" $(_essid_list _) 2>"${_ANSWER}"; then
@ -84,7 +94,7 @@ _wireless() {
_dialog --title " Network Configuration " --no-mouse --infobox "Connecting to '${_WLAN_SSID}'\nwith interface ${_INTERFACE}..." 4 50
_printk off
if [[ -z "${_WLAN_KEY}" ]]; then
iwctl station "${_INTERFACE}" "${_WLAN_CONNECT}" "${_WLAN_SSID}" &>"${_NO_LOG}" && _WLAN_AUTH=1
echo "" | iwctl station "${_INTERFACE}" "${_WLAN_CONNECT}" "${_WLAN_SSID}" &>"${_NO_LOG}" && _WLAN_AUTH=1
else
iwctl --passphrase="${_WLAN_KEY}" station "${_INTERFACE}" "${_WLAN_CONNECT}" "${_WLAN_SSID}" &>"${_NO_LOG}" && _WLAN_AUTH=1
fi
@ -95,7 +105,7 @@ _wireless() {
sleep 2
return 0
else
_dialog --title " ERROR " --no-mouse --infobox "Authentification to ${_WLAN_SSID}' failed. Please configure again!" 3 70
_dialog --title " ERROR " --no-mouse --infobox "Authentification to ${_WLAN_SSID}' failed.\nPlease configure again!" 4 70
sleep 5
return 1
fi