[arch-projects] [netctl][PATCH 3/3] Additional granularity in `netctl list`

Dave Reisner d at falconindy.com
Wed Sep 28 10:11:25 UTC 2016


On Sep 28, 2016 6:07 AM, "Jouke Witteveen via arch-projects" <
arch-projects at archlinux.org> wrote:

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.
---
 docs/netctl.1.txt |  4 ++--
 src/netctl.in     | 10 ++++++----
 src/wifi-menu     |  4 ++--
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/docs/netctl.1.txt b/docs/netctl.1.txt
index 0f63de4..d6d9360 100644
--- a/docs/netctl.1.txt
+++ b/docs/netctl.1.txt
@@ -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.
diff --git a/src/netctl.in b/src/netctl.in
index fcb40f4..305c700 100644
--- a/src/netctl.in
+++ b/src/netctl.in
@@ -29,11 +29,13 @@ END
 }

 list() {
-    local indicators=( '*' ' ' )
+    local indicators=( ' ' '+' '*' ) i=0
     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 - $? ))


i needs to be reset for each loop iteration or else you'll get a
stale/wrong value for an inactive profile following an active one.

+        fi
+        printf '%s %s\n' "${indicators[i]}" "$Profile"
     done
 }

diff --git a/src/wifi-menu b/src/wifi-menu
index 0b18574..de2110b 100755
--- a/src/wifi-menu
+++ b/src/wifi-menu
@@ -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
@@ -272,7 +272,7 @@ 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)
--
2.10.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.archlinux.org/pipermail/arch-projects/attachments/20160928/78e1cdc2/attachment.html>


More information about the arch-projects mailing list