My *nix world

X11 free memory info

On any Linux desktop someone has been created a widget/plug-in kind of application which will display in real time all the system resources, such as CPU, disk and free memory info (memory usage), etc. They are not only very useful but also good looking.

Well, they comes all the time with a price : they consume memory and CPU all of the time. And most of the time you don't really need them to run like every nanosecond, right?. So I have came up with a simple solution: a bash script that you can call it whenever you need to find that info by a keyboard shortcut (the Xfce desktop comes with a handy keyboard shortcut application that I am using for that, the other DM should also provide a such functionality).

Create a simple bash script (eg: showfreem) as the one bellow and then create a keyboard shortcut (eg: Ctrl+Alt+F) that will launch that script every time you need to find out that piece of information.

notify-send -i /usr/share/icons/Tango/${ICON_RES}/devices/media-flash${ICON_EXT} "Free memory" "$(free -m | awk 'NR==2 {print "Total: "$2 " MB"; total=$2} NR==3 {print "Free : "$4 " MB"; free=$4} END {print "Used : " total-free " MB"}')"

Note: don't forget to make your bash script executable by chmod +x showfreem

As you can see this is just one line script code so it is really lightweight and also the consumed memory is released as soon the notification balloon is closed:

free memory infoIf you need/want you can embed much more information within this balloon, it is up to you to extend the above script. If you need help just let me know.

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

The following two tabs change content below.
X11 free memory info

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
Tagged on: ,

Leave a Reply

Your email address will not be published. Required fields are marked *


Get every new post on this blog delivered to your Inbox.

Join other followers: