diff options
| author | Mitsuo Tokumori <[email protected]> | 2024-09-11 04:25:38 +0900 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2024-09-11 04:25:38 +0900 |
| commit | 37ff7062874b72bafa99afe661f42653565ed511 (patch) | |
| tree | 60372bf7fdb94c9034c7d1cc5a17cd7df526c4fc /public/.local/bin/sb-network | |
| parent | dca319b8d9d221f1aaf3a00ee457d202096c66ac (diff) | |
| download | dotfiles-37ff7062874b72bafa99afe661f42653565ed511.tar.gz dotfiles-37ff7062874b72bafa99afe661f42653565ed511.tar.bz2 dotfiles-37ff7062874b72bafa99afe661f42653565ed511.zip | |
RESTRUCTURE. Replicate relative paths in public/
Diffstat (limited to 'public/.local/bin/sb-network')
| -rwxr-xr-x | public/.local/bin/sb-network | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/public/.local/bin/sb-network b/public/.local/bin/sb-network new file mode 100755 index 0000000..0bdbe82 --- /dev/null +++ b/public/.local/bin/sb-network @@ -0,0 +1,52 @@ +#!/bin/sh + +# Prints some network connectivity status in emoji + +case $BLOCK_BUTTON in + 1) setsid -w -f "$TERMINAL" -e pulsemixer; pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;; + 2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;; + 4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;; + 5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;; + 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. +- Middle click to mute. +- Scroll to change." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + + +set_wlan() { + nmcli_status=$(nmcli -t -f TYPE,STATE connection show --active) + wifi=$(echo $nmcli_status | grep -q "802-11-wireless:activated" && echo "📶") + vpn=$(echo $nmcli_status | grep -q "wireguard:activated" && echo "🔒") + wlan="$wifi$vpn" +} + + +set_bt() { + # If bluetooth is on, show number of connected devices and their initials + if ! bluetoothctl show | grep -q "Powered: yes"; then return; fi + ds=$(bluetoothctl devices Connected | cut -d ' ' -f 3-) + if [ -z "$ds" ]; then + bt=$(echo "🦷") + return + fi + N=$(echo "$ds" | wc -l) + ds=$(echo "$ds" | cut -c 1-3 | paste -sd ",") + bt=$(echo "🦷$N:$ds") +} + + +check_network_quarantine() { + # If all wireless devices are (software) blocked, + # change status bar icon and exit + if ! rfkill list | grep -q "Soft blocked: no"; then + echo "🗿" + exit + fi +} + + +check_network_quarantine +set_wlan +set_bt +echo "$wlan$bt" |
