- cd /usr/share/applications
- sudo gedit memcheck.desktop
- Open tweaks
- Click "startup applications"
- Click add, then select "memcheck" application from the list. If it do not appear then you have done some thing wrong.
- Now logout and login. The mem check script should run after user login
[Desktop Entry]
Name=memcheck
Comment=memcheck Tool
Exec=/home/***/projects/mem_alert/memcheck.sh
Terminal=true
Type=Application
Icon=someicon copied from existing .desktop files in same folder
My memcheck.sh looks like:
#!/bin/bash
#Minimum available memory limit, MB
THRESHOLD=2000
#Check time interval, sec
INTERVAL=30
while :
do
free=$(free -m|awk '/^Mem:/{print $4}')
buffers=$(free -m|awk '/^Mem:/{print $6}')
cached=$(free -m|awk '/^Mem:/{print $6}')
available=$(free -m|awk '/^Mem:/{print $7}')
message="Free $free""MB"", buffers $buffers""MB"", cached $cached""MB"", available $available""MB"""
if [ $available -lt $THRESHOLD ]
then
notify-send "Memory is running out!" "$message"
fi
echo $message
sleep $INTERVAL
done