all repos — quickshell @ 4005044f20bc8c20e19cfe88185368da743203dd

A desert-witch desktop shell

bar/scripts/network.sh (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
#!/usr/bin/env bash

# Find the first wireless interface
connection_type=$(iw dev | awk '$1=="Interface"{print $2; exit}') #gets network type (wired/wifi)
if [ -n "$connection_type" ]; then
    network_name=$(iw dev $connection_type link | awk -F': ' '/^\s*SSID:/ {print $2}')
    signal_strength=$(iw dev $connection_type link | awk '/signal:/ {print $2}')
    if (( sig >= -50 )); then
        bars=4
        elif (( sig >= -60 )); then
            bars=3
        elif (( sig >= -70 )); then
            bars=2
        elif (( sig >= -80 )); then
            bars=1
        else
            bars=0
    fi
    echo -n "$bars"+"$network_name"
else
    echo -n "disconnected"
fi