dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit 2bc55735d3aafd9d283fa74d4b83f1f0e612f648
parent 35673894b062ed55d6899cf07fa4d8a645367d3d
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 25 Apr 2021 11:25:41 +0100

.s/d/mem: use dmesg on openbsd

Diffstat:
M.scripts/dwmblocks/mem | 29++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/.scripts/dwmblocks/mem b/.scripts/dwmblocks/mem @@ -1,14 +1,21 @@ #!/bin/sh -# -# dwmblocks/mem -# Created by Hayden Hamilton -# -# haydenvh.com -# Copyright (c) 2019 Hayden Hamilton. +# Copyright (c) 2019-2021 Hayden Hamilton. -mem=$(free -h | awk '{print $3 "/" $2}' | head -n 2 | tail -n 1) -echo "$mem" | grep 'Mi/' >/dev/null && col="^c#00aa00^" -echo "$mem" | grep '1\.[0-4]Gi/' >/dev/null && col="^c#aaaa00^" -echo "$mem" | grep '1\.[5-9]Gi/' >/dev/null && col="^c#aa7700^" -echo "$mem" | grep '2\..Gi/' >/dev/null && col="^c#aa0000^" +[ "$(uname)" = "Linux" ] && { + mem=$(free -h | awk '{print $3 "/" $2}' | head -n 2 | tail -n 1) + echo "$mem" | grep 'Mi/' >/dev/null && col="^c#00aa00^" + echo "$mem" | grep '1\.[0-4]Gi/' >/dev/null && col="^c#aaaa00^" + echo "$mem" | grep '1\.[5-9]Gi/' >/dev/null && col="^c#aa7700^" + echo "$mem" | grep '2\..Gi/' >/dev/null && col="^c#aa0000^" +} +[ "$(uname)" = "OpenBSD" ] && { + total=$(dmesg | grep "^real mem" | awk '{print $5}' | tr -d 'MB()') + avail=$(dmesg | grep "^avail mem" | awk '{print $5}' | tr -d 'MB()') + used=$(echo "$total - $avail" | bc) + mem="${used}M/${avail}M" + [ $used -le 1000 ] && col="^c#00aa00^" + [ $used -gt 1000 ] && col="^c#aaaa00^" + [ $used -gt 1500 ] && col="^c#aa7700^" + [ $used -gt 2000 ] && col="^c#aa0000^" +} echo "[M ${col}${mem}]"