def notify_send(title, message=None): try: msg = get_msg(title, message) logger.info("NOTIFY-SEND: %s", msg) procutil.call(['notify-send', msg]) except proctuil.WrappedCalledProcessError: logger.exception("notify-osd failed")
def raise_window(hex_code): try: procutil.call(['wmctrl', '-i', '-a', hex_code]) return True except procutil.WrappedCalledProcessError: logger.exception("Couldn't raise the input window...") return False
def name_from_pid(pid): """ E.g. ps -p 23827 -o comm= """ name = procutil.call(['ps', '-p', str(pid), '-o', 'comm=']) return name
def send_dbus(service, path, method, args=[], qdbus_args=[]): """ So basically, I can't figure out threading with dbus in python, so just invoke qdbus command line program instead to send a reply... qdbus im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.PurpleConvIm $conversation qdbus im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.PurpleConvImSend $convIMResult 'hello world' """ def stringify(xs): return [str(x) for x in xs] cmd = ["qdbus"] + stringify(qdbus_args) + [service, path, method] + stringify(args) return procutil.call(cmd)
def send_dbus(service, path, method, args=[], qdbus_args=[]): """ So basically, I can't figure out threading with dbus in python, so just invoke qdbus command line program instead to send a reply... qdbus im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.PurpleConvIm $conversation qdbus im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.PurpleConvImSend $convIMResult 'hello world' """ def stringify(xs): return [str(x) for x in xs] cmd = ["qdbus"] + stringify(qdbus_args) + [service, path, method ] + stringify(args) return procutil.call(cmd)