aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/sysmon
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-02-18 18:08:51 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2023-02-18 18:08:51 +0100
commit798ed274c84f265bdf9a28fd171ff36807ff1b27 (patch)
treede94fe4cd2269e73269ee4f25c7a0211002490c8 /.local/bin/sysmon
parent8b8325da143e88cc1144f5ddc26f717d9b98aafd (diff)
dotfiles changes
Diffstat (limited to '.local/bin/sysmon')
-rwxr-xr-x.local/bin/sysmon21
1 files changed, 21 insertions, 0 deletions
diff --git a/.local/bin/sysmon b/.local/bin/sysmon
new file mode 100755
index 0000000..d04b5a3
--- /dev/null
+++ b/.local/bin/sysmon
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+cpu_usage() {
+ first=$(grep 'cpu ' /proc/stat)
+ sleep 0.05
+ second=$(grep 'cpu ' /proc/stat)
+ usage=$(printf "%s\n%s\n" "$first" "$second" | awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1); }' | sed -e 's/\..*//g')
+
+ printf "󰇅 "
+ bar "$usage"
+}
+
+ram_usage() {
+ printf " "
+ usage=$(free | awk '/Mem/ { print $3 / $2 * 100 }' | sed -e 's/\..*//g')
+ bar "$usage"
+}
+
+
+ram_usage
+cpu_usage