Last active
August 29, 2015 14:22
-
-
Save jamesrr39/3ac9ca32e23073e2e77a to your computer and use it in GitHub Desktop.
Notify how much swap space is available (Linux)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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