My scripts for startup, dmenu, and the command line
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

bar.sh 1.6 KiB

4 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. font=;
  3. clock() {
  4. date '+%H:%M %d-%m-%y'
  5. }
  6. # get the battery capacity and status
  7. battery() {
  8. BATC=/sys/class/power_supply/BAT0/capacity
  9. BATS=/sys/class/power_supply/BAT0/status
  10. # prepend percentage with a '+' if charging, '-' otherwise
  11. test "`cat $BATS`" = "Charging" && echo -n '+' || echo -n '-'
  12. echo $BATC
  13. }
  14. volume() {
  15. # get master volume level from amixer
  16. # parse amixer output to get ONLY the level. Will output "84%"
  17. # we need `uniq` because on some hardware, The master is listed twice in
  18. # "Front Left" and Front Right" (because laptop speakers I guess)
  19. amixer get Master | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p'| uniq
  20. }
  21. network() {
  22. infs=$(ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p')
  23. lo=$(echo $infs | awk '{print $1}')
  24. int1=$(echo $infs | awk '{print $2}')
  25. int2=$(echo $infs | awk '{print $3}')
  26. #iwconfig returns an error code if the interface tested has no wireless extensions
  27. if iwconfig $int1 >/dev/null 2>&1; then
  28. wifi=$int1
  29. eth0=$int2
  30. else
  31. wifi=$int2
  32. eth0=$int1
  33. fi
  34. ip link show $eth0 | grep 'state UP' >/dev/null && int=$eth0 || int=$wifi
  35. printf $int
  36. ping -c1 -s1 8.8.8.8 >/dev/null 2>&1 && echo "connected" || echo "disconnected"
  37. }
  38. # get cpu load (TODO- get this using iostat)
  39. # get ram usage
  40. memused() {
  41. # store the total and free memory in two variables
  42. t=$(grep -E 'MemTotal' /proc/meminfo |awk '{print $2}')
  43. f=$(grep -E 'MemFree' /proc/meminfo |awk '{print $2}')
  44. b=$(grep -E '^(Buffers)' /proc/meminfo |awk '{print $2}')
  45. c=$(grep -E '^(Cached)' /proc/meminfo |awk '{print $2}')
  46. # then, calcultate the percentage of memory used
  47. bc | "100($t -$f -$c -$b) / $t"
  48. }