diff options
author | Xiao Pan <gky44px1999@gmail.com> | 2024-02-23 18:17:46 -0800 |
---|---|---|
committer | Xiao Pan <gky44px1999@gmail.com> | 2024-02-23 18:17:46 -0800 |
commit | 4299615002711bfc2e2ce9477c05dc3839161c50 (patch) | |
tree | 3f0c28a504845cf317a4b892811e937caad15b47 /sh | |
parent | a8e21184857f8d7ddfa06251516b39d301ea4dc2 (diff) |
faster and less code
Diffstat (limited to 'sh')
-rwxr-xr-x | sh/sbar | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -15,16 +15,11 @@ update_time () { update_net () { net="$(if nmcli -t --fields type,state device | grep -q '^\(ethernet\|wifi\):connected$'; then echo 1; else echo 0; fi)" - nm_device_state="$(nmcli -t --fields device,state device)" - vpn="$( - if echo "$nm_device_state" | grep -q '^wg_ka:connected$'; then - echo K - elif echo "$nm_device_state" | grep -q '^wg_studio:connected$'; then - echo S - else - echo 0 - fi - )" + case "$(nmcli -t --fields device,state device)" in + *wg_ka:connected*) vpn=K;; + *wg_studio:connected*) vpn=S;; + *) vpn=0;; + esac } update_vol () { |