Skip to content

Instantly share code, notes, and snippets.

@jamii
Created January 8, 2015 01:24
Show Gist options
  • Save jamii/52ddf1fa3b4ddf072a48 to your computer and use it in GitHub Desktop.
Save jamii/52ddf1fa3b4ddf072a48 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import gi.repository
from gi.repository import Gio, GLib
import sys
import subprocess
session_bus = Gio.BusType.SESSION
cancellable = None
proxy_property = 0
interface_properties_array = None
destination = "org.freedesktop.Notifications"
path = "/org/freedesktop/Notifications"
interface = destination
method = "Notify"
application_name = "inform"
id_num_to_replace = 0
icon = "/usr/share/icons/Tango/32x32/status/sunny.png"
actions_list = []
hints_dict = {}
display_milliseconds = 5000
timeout = -1
command = sys.argv[1]
while True:
title = command
results = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
text = results[0].decode('utf8') + "\n\n" + results[1].decode('utf8')
connection = Gio.bus_get_sync(session_bus, cancellable)
notify = Gio.DBusProxy.new_sync( connection, proxy_property, interface_properties_array, destination, path, interface, cancellable)
args = GLib.Variant('(susssasa{sv}i)', ( application_name, id_num_to_replace, icon, title, text, actions_list, hints_dict, display_milliseconds))
result = notify.call_sync(method, args, proxy_property, timeout, cancellable)
id_num_to_replace = result.unpack()[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment