Last active 1 month ago

nuno revised this gist 1 month ago. Go to revision

1 file changed, 33 insertions

gistfile1.txt(file created)

@@ -0,0 +1,33 @@
1 + sed -n '/local drop_word/,/^}/p' \
2 + /etc/wireguard/wgctl/commands/activity.command.sh | head -50
3 + local drop_word="drops"
4 + [[ "$drops" -eq 1 ]] && drop_word="drop"
5 + printf " \033[1m%s\033[0m \033[2m↓\033[0m%s \033[2m↑\033[0m%s %${w_drops}s %s\n" \
6 + "$name_pad" "$rx_pad" "$tx_pad" "$drops" "$drop_word"
7 + ;;
8 +
9 + service)
10 + $skip_peer && continue
11 +
12 + local peer dest_display drop_count
13 + IFS='|' read -r peer dest_display drop_count <<< "$rest"
14 +
15 + # Compute padding to align drop count with peer drop column
16 + # Service row visible prefix: " → " (6) + ${#dest_display}
17 + local arrow_prefix=" → "
18 + local prefix_bytes=${#arrow_prefix} # = 8 due to → being 3 bytes
19 + local prefix_len=$(( prefix_bytes + ${#dest_display} ))
20 + # local prefix_len=$(( 6 + ${#dest_display} ))
21 + local pad_n=$(( drops_col - prefix_len ))
22 + [[ $pad_n -lt 1 ]] && pad_n=1
23 +
24 + local svc_drop_word="drops"
25 + [[ "$drop_count" -eq 1 ]] && svc_drop_word="drop"
26 + printf " \033[2m→\033[0m %s%*s %${w_drops}s %s\n" \
27 + "$dest_display" "$pad_n" "" "$drop_count" "$svc_drop_word"
28 + ;;
29 + esac
30 + done <<< "$data"
31 +
32 + echo ""
33 + }
Newer Older