dwm-bar for archlinux
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.

33 lines
1.1 KiB

  1. #!/bin/sh
  2. # A dwm_bar function to display information regarding system memory, CPU temperature, and storage
  3. # Joe Standring <git@joestandring.com>
  4. # GNU GPLv3
  5. df_check_location='/home'
  6. dwm_resources () {
  7. # get all the infos first to avoid high resources usage
  8. free_output=$(free -h | grep Mem)
  9. df_output=$(df -h $df_check_location | tail -n 1)
  10. # Used and total memory
  11. MEMUSED=$(echo $free_output | awk '{print $3}')
  12. MEMTOT=$(echo $free_output | awk '{print $2}')
  13. # CPU temperature
  14. CPU=$(top -bn1 | grep Cpu | awk '{print $2}')%
  15. #CPU=$(sysctl -n hw.sensors.cpu0.temp0 | cut -d. -f1)
  16. # Used and total storage in /home (rounded to 1024B)
  17. STOUSED=$(echo $df_output | awk '{print $3}')
  18. STOTOT=$(echo $df_output | awk '{print $2}')
  19. STOPER=$(echo $df_output | awk '{print $5}')
  20. printf "%s" "$SEP1"
  21. if [ "$IDENTIFIER" = "unicode" ]; then
  22. printf "💻 MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER"
  23. else
  24. printf "STA | MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER"
  25. fi
  26. printf "%s\n" "$SEP2"
  27. }
  28. dwm_resources