Another copy of my dotfiles. Because I don't completely trust GitHub.
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.

35 lines
920 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #!/bin/bash
  2. source ~/.config/config.env
  3. get_ssid(){
  4. networks=$(connmanctl services | \
  5. awk -F ' +' '{ service_id=$NF; $NF=""; $1=""; name=substr($0, 2, length-2); gsub(/[^a-zA-Z0-9-]/, "_", name) }
  6. name { print name, service_id }')
  7. while read -r name service_id; do
  8. if [ $(connmanctl services "$service_id" | awk '$1 == "State" { print $3 }') = "online" ]; then
  9. echo "$name"
  10. break
  11. fi
  12. done <<< "$networks"
  13. }
  14. is_eth_used=$(cat /sys/class/net/$ETH_IT/carrier)
  15. is_wlan_used=$(cat /sys/class/net/$WLAN_IT/carrier)
  16. echo -n "^c#88c0d0^"
  17. if [ "$is_eth_used" -eq 1 ]; then # wired network is carrying
  18. icon=" ^d^ " #uF6FF
  19. elif [ "$is_wlan_used" -eq 1 ]; then # wireless network is carrying
  20. ssid=$(get_ssid)
  21. icon=" ^d^" #uF1EB
  22. else
  23. icon=" ^d^" #uf128 # no network
  24. fi
  25. echo -n $icon
  26. case $BLOCK_BUTTON in
  27. 1) ~/.local/bin/connman_dmenu;;
  28. esac