Configuration file for dwm-bar on macbook air
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

  1. #!/bin/sh
  2. # A dwm_bar function to show the current network connection/SSID, Wifi Strength, private IP using Connmanctl.
  3. # procrastimax <heykeroth.dev@gmail.com>
  4. # GNU GPLv3
  5. # Dependencies: connman
  6. dwm_connman () {
  7. printf "%s" "$SEP1"
  8. if [ "$IDENTIFIER" = "unicode" ]; then
  9. printf "🌐 "
  10. else
  11. printf "NET "
  12. fi
  13. # get the connmanctl service name
  14. # this is a UID starting with 'vpn_', 'wifi_', or 'ethernet_', we dont care for the vpn one
  15. # if the servicename string is empty, there is no online connection
  16. SERVICENAME=$(connmanctl services | grep -E "^\*AO|^\*O" | grep -Eo 'wifi_.*|ethernet_.*')
  17. if [ ! "$SERVICENAME" ]; then
  18. printf "OFFLINE"
  19. printf "%s\n" "$SEP2"
  20. return
  21. else
  22. STRENGTH=$(connmanctl services "$SERVICENAME" | sed -n -e 's/Strength =//p' | tr -d ' ')
  23. CONNAME=$(connmanctl services "$SERVICENAME" | sed -n -e 's/Name =//p' | tr -d ' ')
  24. IP=$(connmanctl services "$SERVICENAME" | grep 'IPv4 =' | awk '{print $5}' | sed -n -e 's/Address=//p' | tr -d ',')
  25. fi
  26. # if STRENGTH is empty, we have a wired connection
  27. if [ "$STRENGTH" ]; then
  28. printf "%s %s %s%%" "$IP" "$CONNAME" "$STRENGTH"
  29. else
  30. printf "%s %s" "$IP" "$CONNAME"
  31. fi
  32. printf "%s\n" "$SEP2"
  33. }
  34. dwm_connman