#! /usr/bin/env python3

from re import search, IGNORECASE
import yaml
from subprocess import check_output
import sys

def getWindowName():
    return check_output("xdotool getwindowfocus getwindowname".split()).decode('utf8')


def main(*args):
    if not args:
        return 1

    windowName = getWindowName()

    for filename in args:
        with open(filename) as f:
            d = yaml.load(f)
            for regex, items in d.items():
                if search(regex, windowName, flags=IGNORECASE):
                    for item in items:
                        print(item, end='\0', flush=False)

if __name__ == '__main__':
    main(*sys.argv[1:])
