diff options
| author | MineralwaterXu <[email protected]> | 2020-12-01 22:24:45 +0800 |
|---|---|---|
| committer | MineralwaterXu <[email protected]> | 2020-12-01 22:24:45 +0800 |
| commit | b5da5b662ac4516a762d086d03af90f71665f71d (patch) | |
| tree | 93b83037fce0f7b0f756a85be1dad751f9fb37a9 /dwmbar-functions/dwm_resources.sh | |
| parent | 22ba6040a38c7aadce1100fb9c02c4c120618296 (diff) | |
autostart and dwmstatus
Diffstat (limited to 'dwmbar-functions/dwm_resources.sh')
| -rwxr-xr-x | dwmbar-functions/dwm_resources.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/dwmbar-functions/dwm_resources.sh b/dwmbar-functions/dwm_resources.sh new file mode 100755 index 0000000..ca064c2 --- /dev/null +++ b/dwmbar-functions/dwm_resources.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# A dwm_bar function to display information regarding system memory, CPU temperature, and storage +# Joe Standring <[email protected]> +# GNU GPLv3 + +dwm_resources () { + # Used and total memory + MEMUSED=$(free -h | awk '(NR == 2) {print $3}') + MEMTOT=$(free -h |awk '(NR == 2) {print $2}') + # CPU temperature + CPU=$(sysctl -n hw.sensors.cpu0.temp0 | cut -d. -f1) + # Used and total storage in /home (rounded to 1024B) + STOUSED=$(df -h | grep '/home$' | awk '{print $3}') + STOTOT=$(df -h | grep '/home$' | awk '{print $2}') + STOPER=$(df -h | grep '/home$' | awk '{print $5}') + + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + printf "💻 MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER" + else + printf "STA | MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER" + fi + printf "%s\n" "$SEP2" +} + +dwm_resources |
