Commit d1c992b7 authored by Jouke Witteveen's avatar Jouke Witteveen
Browse files

Additional granularity in `netctl list`

Distinguish between started profiles and online profiles in the output
of the list subcommand of netctl.
To be consistent in symbol usage, the wifi-menu flags have changed too.
parent e43a8221
......@@ -24,8 +24,8 @@ OPTIONS
The following commands are understood:
*list*::
List all available profiles. Active profiles will be marked with a
`*'.
List all available profiles. Online profiles will be marked with a
`*', otherwise active profiles will be marked with a `+'.
*store*::
Saves which profiles are currently active.
......
......@@ -85,6 +85,10 @@ GENERAL OPTIONS
to be a list of profiles that this profile requires. The meaning is
the same as 'After' in *systemd.unit*(5).
'WaitOnline='::
Set to `++yes++' to consider the profile activated only when it is
online.
'ExecUpPost='::
A command that is executed after a connection is established. If the
specified command returns anything other than 0 (success), *netctl*
......
......@@ -58,7 +58,7 @@ bring_interface_down() {
## Indicate that the network stack for the profile is up
network_ready() {
if ! is_yes "${NETWORK_READY:-no}"; then
if ! is_yes "${WaitOnline:-no}" && ! is_yes "${NETWORK_READY:-no}"; then
do_debug systemd-notify --ready
NETWORK_READY=yes
fi
......@@ -68,6 +68,9 @@ network_ready() {
# $1: status string, should be "online" when the profile gets connected
network_status() {
do_debug systemd-notify --status="$1"
if [[ $1 == "online" ]] && is_yes "${WaitOnline:-no}"; then
WaitOnline=no network_ready
fi
}
......
......@@ -29,11 +29,15 @@ END
}
list() {
local indicators=( '*' ' ' )
local indicators=( ' ' '+' '*' ) i
list_profiles | while read -r Profile; do
sd_call "is-active --quiet" "$Profile" &> /dev/null
# Make the return value boolean
printf '%s %s\n' "${indicators[!! $?]}" "$Profile"
if sd_call "is-active --quiet" "$Profile" &> /dev/null; then
[[ $(sd_status_text "$Profile") == "online" ]]
(( i = 2 - $? ))
else
(( i = 0 ))
fi
printf '%s %s\n' "${indicators[i]}" "$Profile"
done
}
......
......@@ -65,7 +65,7 @@ init_profiles()
# Builds ENTRIES as an argument list for dialog based on scan results in $1.
init_entries()
{
local i=0 flags signal ssid
local i=0 sep=$'\t' flags signal ssid
while IFS=$'\t' read -r signal flags ssid; do
ENTRIES[i++]="--" # $ssid might look like an option to dialog.
ENTRIES[i++]=$ssid
......@@ -73,7 +73,7 @@ init_entries()
if in_array "$(ssid_to_profile "$ssid")" "${GENERATED[@]}"; then
ENTRIES[i]="." # Automatically generated
else
ENTRIES[i]="+" # Handmade
ENTRIES[i]=":" # Handmade
fi
else
ENTRIES[i]=" " # Not present
......@@ -82,11 +82,11 @@ init_entries()
ENTRIES[i]="*" # Currently connected
fi
if [[ "$flags" =~ WPA2|WPA|WEP ]]; then
ENTRIES[i]+=":${BASH_REMATCH[0],,}"
ENTRIES[i]+="${sep}${BASH_REMATCH[0],,}"
else
ENTRIES[i]+=":none"
ENTRIES[i]+="${sep}none"
fi
ENTRIES[i]+=" :$signal"
ENTRIES[i]+=" ${sep}${signal}"
(( ++i ))
done < "$1"
}
......@@ -272,10 +272,9 @@ if (( RETURN == 0 )); then
MSG="Select the network you wish to use
Flags description:
* - active connection present
+ - handmade profile present
: - handmade profile present
. - automatically generated profile present"
CHOICE=$(dialog --column-separator : --menu "$MSG" 24 50 12 \
"${ENTRIES[@]}" --stdout)
CHOICE=$(dialog --menu "$MSG" 24 50 12 "${ENTRIES[@]}" --stdout)
RETURN=$?
if (( RETURN == 0 )); then
connect_to_ssid "$CHOICE"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment