dot

packages and services management
Log | Files | Refs | README

commit 4dbaba82bc157376858df5d784c94407f45c0ba9
parent 1d46cc1854245d362544e63fb72dfe92cc4bb6fd
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sun, 25 Jun 2017 01:31:59 +0200

display memory (from neofetch)

Diffstat:
Mbin/status | 43+++++++++++++++++++++++++++++++++++++++----
Mx11/.xinitrc | 3+--
2 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/bin/status b/bin/status @@ -15,7 +15,7 @@ status_mail() then mail="$(find "$MAIL/new" -type f | wc -l | tr -d '\t ')" mail="${mail#0}" - mail="${mail:+$mail mail}" + mail="${mail:+$mail MAIL}" printf %s "$mail" fi @@ -28,16 +28,51 @@ status_date() } +# from neofetch(1) + +status_memory() +{ + case "$(uname -s)" in + (Linux) + while IFS=': ' read -r key value unit + do + case "$key" in + (MemTotal) total=$((value / 1024)) ;; + (MemFree ) used=$(((total - value / 1024))) ;; + esac + done < /proc/meminfo + ;; + + (FreeBSD) + pagesize=$(sysctl -n hw.pagesize) + inactive=$(($(sysctl -n vm.stats.vm.v_inactive_count) * pagesize)) + unused=$(( $(sysctl -n vm.stats.vm.v_free_count) * pagesize)) + cache=$(( $(sysctl -n vm.stats.vm.v_cache_count) * pagesize)) + total=$(( $(sysctl -n hw.physmem) / 1024 / 1024)) + free=$(((inactive + unused + cache) / 1024 / 1024)) + used=$((total - free)) + ;; + + (OpenBSD) + total=$(($(sysctl -n hw.physmem) / 1024 / 1024)) + used=$(($(vmstat | awk 'END{printf $4}') / 1024)) + ;; + esac + + printf 'MEM %sM/%sM' "$((used))" "$((total))" +} + + status_cpu() { - uptime | sed -r 's/.*load average[^ ] *([^,]*).*/\1/' + uptime | sed -r 's/.*load average[^ ] *([^,]*).*/CPU \1/' } status_battery() { [ -f /sys/class/power_supply/*/capacity ] && - printf '%d%%' "`cat /sys/class/power_supply/*/capacity`" + printf 'BAT %d%%' "`cat /sys/class/power_supply/*/capacity`" } @@ -57,4 +92,4 @@ main() } -[ $# -gt 0 ] && main "$@" || main mail cpu battery date +[ $# -gt 0 ] && main "$@" || main mail memory cpu battery date diff --git a/x11/.xinitrc b/x11/.xinitrc @@ -5,8 +5,7 @@ xsetroot -solid '#000000' xset +fp "$CONFIG/fonts" while xsetroot -name "$(status)" -do - sleep 5 +do sleep 3 done & exec dwm