def main():
    files = os.environ["KONIX_NOTMUCH_SAVED_SEARCHES"].split(os.pathsep)
    default_letter = "i"
    existing_files = [file for file in files if os.path.exists(file)]
    if not existing_files:
      konix_notify.main("No valid file in KONIX_NOTMUCH_SAVED_SEARCHES")
      sys.exit(1)
    file = existing_files[0]
    config = ConfigParser.ConfigParser()
    config.optionxform = str    # keys not converted into lower case
    config.read(file)
    sections = config.sections()
    if "default" in sections:
        default_letter = config.get("default", "icon_letter")
    sections = [section for section in sections if section != "default"]
    import notmuch
    db = notmuch.Database()
    for section in config.sections():
        try:
            icon_letter = config.get(section, "icon_letter")
        except:
            icon_letter = None
        search = config.get(section, "search")
        if icon_letter:
            q = notmuch.Query(db, search)
            res = q.count_messages()
            if res != 0:
                write(icon_letter)
                sys.exit(0)
    write(default_letter)
    sys.exit(1)
Example #2
0
def main(uri):
    u = urlparse.urlparse(uri)

    if u.scheme == 'mailto':
        detach_open(['xterm', '-e', 'mail', u.path])
    elif u.scheme == 'xmpp':
        # Someone check for safe arguments to gajim-remote
        detach_open(['gajim-remote', 'open_chat', uri])
    elif u.scheme == 'git':
        detach_open(['git', 'clone', '--', uri], cwd=os.path.expanduser('~/src'))
    elif u.scheme == 'editor':
        dwim = subprocess.call(
            ['zenity', '--question', '--text', "Do what I mean ? "+uri]
        )
        if dwim == 0:
            detach_open(['konix_uri_dwim.py', uri],)
    elif u.scheme == 'smb' or u.scheme == "afp":
        smb_mount = os.environ.get("KONIX_SMB_MOUNT", None)
        if not smb_mount:
            konix_notify.main("KONIX_SMB_MOUNT not set")
            print("USED")
        else:
            real_path = os.path.join(smb_mount, u.netloc, u.path[1:])
            konix_notify.main("Opening %s with mimeopen" % real_path)
            detach_open(['mimeopen', "-n", real_path])
Example #3
0
def get_from_clipboard(button=None, event=None):
    global entry
    clipboard_text = gtk.Clipboard(selection="PRIMARY").wait_for_text() or \
                     gtk.Clipboard(selection="CLIPBOARD").wait_for_text() or ""
    entry.set_text(clipboard_text)
    entry.grab_focus()
    konix_notify.main("Updated the entry with clipboard content")
Example #4
0
def bell():
    konix_notify.main("ALARM !")
    try:
        import pygame
        pygame.init()
        pygame.mixer.music.load(
            os.path.join(
                os.environ["KONIX_DEVEL_DIR"],
                "data",
                "alarm.ogg"
            )
        )
        pygame.mixer.music.play()
    except:
        pass
Example #5
0
def notify(message, type_):
    """Display a notification"""
    konix_notify.main(message, type_=type_)
    return False
Example #6
0
#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
import konix_notify
import argparse

parser = argparse.ArgumentParser(description="Display a message using the notification daemon.")

parser.add_argument(
    "-d", "--duration", default=3000, type=int, help="The duration of the notification in ms, defaults to 3000"
)

parser.add_argument("-u", "--unique", action="store_true", help="Unique message")

parser.add_argument("message", type=str, nargs="*", help="The message")

args = parser.parse_args()

message = " ".join(args.message)
konix_notify.main(message, unique=args.unique, duration=args.duration)
Example #7
0
import argparse

parser = argparse.ArgumentParser(
    description="Display a message using the notification daemon.",
)

parser.add_argument('-d', '--duration', default=3000, type=int,
                    help="The duration of the notification in ms, defaults to 3000")

parser.add_argument('-u', '--unique', action="store_true",
                    help="Unique message")

parser.add_argument('-t', '--type', type=str,
                    help="Type of the notification",
                    choices=["normal", "annoying", "boring"],
                    default="normal",
)

parser.add_argument('-o', '--to-phone', action="store_true",
                    help="Use the phone",
)

parser.add_argument('message', type=str, nargs="*",
                    help="The message")

args = parser.parse_args()

message = ' '.join(args.message)
konix_notify.main(message, unique=args.unique, duration=args.duration,
                  type_=args.type, to_phone=args.to_phone)
Example #8
0
#!/usr/bin/python
import sys
import konix_notify

if __name__ == "__main__":
	if len(sys.argv) <= 1:
		exit(1)
	message = ' '.join(sys.argv[1:])
	konix_notify.main(message,True)