summaryrefslogtreecommitdiff
path: root/ar/.local/bin/statusbar/sb-memory
diff options
context:
space:
mode:
Diffstat (limited to 'ar/.local/bin/statusbar/sb-memory')
-rwxr-xr-xar/.local/bin/statusbar/sb-memory10
1 files changed, 7 insertions, 3 deletions
diff --git a/ar/.local/bin/statusbar/sb-memory b/ar/.local/bin/statusbar/sb-memory
index bc7085a..804fd91 100755
--- a/ar/.local/bin/statusbar/sb-memory
+++ b/ar/.local/bin/statusbar/sb-memory
@@ -13,6 +13,10 @@ case $BLOCK_BUTTON in
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
-[ $(xrandr | grep "\*" | awk '{print $1}' | sed 's/x[0-9]*//g') -lt 1920 ] &&
- free --mebi | sed -n '2{p;q}' | awk '{printf ("🐏%d%%\n", ($3/$2)*100+0.5 )}' ||
- free --mebi | sed -n '2{p;q}' | awk '{printf ("🐏%dGB/%dGB", $3/1000+0.5,$2/1000+0.5)}'
+width=$(xrandr | grep "\*" | awk '{print $1}' | sed 's/x[0-9]*//g' | head -n1)
+
+if [ -n "$width" ] && [ "$width" -eq "$width" ] 2>/dev/null; then
+ [ "$width" -lt 1920 ] &&
+ free --mebi | sed -n '2{p;q}' | awk '{printf ("🐏%d%%\n", ($3/$2)*100+0.5 )}' ||
+ free --mebi | sed -n '2{p;q}' | awk '{printf ("🐏%dGB/%dGB", $3/1000+0.5,$2/1000+0.5)}'
+fi