Skip to content

Instantly share code, notes, and snippets.

@jamesrr39
Last active August 29, 2015 14:22
Show Gist options
  • Save jamesrr39/3ac9ca32e23073e2e77a to your computer and use it in GitHub Desktop.
Save jamesrr39/3ac9ca32e23073e2e77a to your computer and use it in GitHub Desktop.
Notify how much swap space is available (Linux)
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import re
from gi.repository import Notify
def send_message(summary, message):
Notify.init (summary)
notification = Notify.Notification.new (summary,message,"dialog-information")
notification.show ()
def get_swap_memory_data():
file = open("/proc/meminfo", "r")
lines = []
for line in file:
if re.search("Swap", line):
lines.append(line.replace("\n",""))
return lines
send_message("Swap Summary", "\n".join(get_swap_memory_data()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment