added quickshell and updated zsh
This commit is contained in:
14
home/hypr/quickshell/scripts/get_mem.sh
Executable file
14
home/hypr/quickshell/scripts/get_mem.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Read memory usage from /proc/meminfo
|
||||
mem_total=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
||||
mem_avail=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
|
||||
|
||||
if [ -n "$mem_total" ] && [ -n "$mem_avail" ] && [ "$mem_total" -gt 0 ]; then
|
||||
mem_used=$((mem_total - mem_avail))
|
||||
mem_percent=$((mem_used * 100 / mem_total))
|
||||
used_gb=$(awk "BEGIN {printf \"%.1f\", $mem_used/1048576}")
|
||||
total_gb=$(awk "BEGIN {printf \"%.1f\", $mem_total/1048576}")
|
||||
echo "{\"percent\": $mem_percent, \"used_gb\": \"$used_gb\", \"total_gb\": \"$total_gb\"}"
|
||||
else
|
||||
echo "{\"percent\": 0, \"used_gb\": \"0\", \"total_gb\": \"0\"}"
|
||||
fi
|
||||
Reference in New Issue
Block a user