You are not logged in.

#1 2011-12-28 12:02:56

Registered: 2011-08-10
Posts: 49

Show free RAM in i3status [SOLVED]

I am trying to show the available RAM in the i3status bar. However, the manual only provides instructions on how to provide the available hard disk space, not RAM. Ideally, I show the total available RAM in MB or GB. As a newbie, I have two questions about this:

1. Is there a built-in way to display the available RAM in i3status?

2. If I need to use a script that gets the available RAM, what is the best way to do this? I have found several methods, but am wondering what is considered a good practice? For instance, I found the following:

cat /proc/meminfo | grep MemFree

From: … oc-meminfo

vmstat 1 2 | sed -n '$ p' | awk '{print $4}'

From: … l-ram.html

With the second script I obtain a number, which I figure is easier to divide and show as MB or GB. However, it appears to be slow. Is this the right way to do so?

Last edited by george55 (2012-12-30 19:43:03)


#2 2011-12-28 12:47:57

Registered: 2009-05-06
Posts: 25,440

Re: Show free RAM in i3status [SOLVED]

awk '/MemFree/ {print $2}' /proc/meminfo

will give you a number (representing kB).


#3 2012-12-30 19:42:22

Registered: 2011-08-10
Posts: 49

Re: Show free RAM in i3status [SOLVED]

Excellent, thanks!


#4 2016-08-17 23:08:37

Registered: 2016-08-17
Posts: 1

Re: Show free RAM in i3status [SOLVED]

sorry for the necrobump but this can actually help someone!

awk can do a bit more work and get you the percentage of used or available memory:

# used memory
awk '/MemTotal/ {memtotal=$2}; /MemAvailable/ {memavail=$2}; END { printf("%.0f", (100- (memavail / memtotal * 100))) }' /proc/meminfo

# available memory
awk '/MemTotal/ {memtotal=$2}; /MemAvailable/ {memavail=$2}; END { printf("%.0f", memavail / memtotal * 100) }' /proc/meminfo

output will be a rounded up percentage of a hole number ex: 50%

Last edited by redowk (2016-08-17 23:11:01)


#5 2016-08-23 11:02:37

Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 8,584

Re: Show free RAM in i3status [SOLVED]

Thanks for sharing, redowk. However, I'm going to take this opportunity to close this old thread.

Mobo: MSI X299 TOMAHAWK ARCTIC // Processor: Intel Core i7-7820X 3.6GHz // GFX: nVidia GeForce GTX 970 // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 5x 1TB HDD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.


Board footer

Powered by FluxBB