Example #1
0
async def main(connection):
    async with iterm2.CustomControlSequenceMonitor(connection, COMMAND, r'^.*$') as mon:
        while True:
            match = await mon.async_get()
            try:
                subprocess.run(['say', match.group(0)])
            except:
                traceback.print_tb(sys.exec_info()[2])
Example #2
0
async def main(connection):
    async with iterm2.CustomControlSequenceMonitor(connection, COMMAND,
                                                   r'^.*$') as mon:
        while True:
            match = await mon.async_get()
            try:
                filename = locate_sound(match.group(0))
                subprocess.run(["afplay", filename])
            except:
                traceback.print_tb(sys.exc_info()[2])
Example #3
0
 async def watch(session_id):
     session = app.get_session_by_id(session_id)
     async with iterm2.CustomControlSequenceMonitor(connection,
                                                    "remote-bbedit", r'.*',
                                                    session_id) as mon:
         while True:
             match = await mon.async_get()
             os.system("/usr/local/bin/bbedit --wait --resume -- " +
                       match.string)
             await session.async_send_text("Y")
Example #4
0
async def main(connection):
    # This is an example of using an asyncio context manager to register a custom control
    # sequence. You can send a custom control sequence by issuing this command in a
    # terminal session in iTerm2 while this script is running:
    #
    # printf "\033]1337;Custom=id=%s:%s\a" "shared-secret" "create-window"
    async with iterm2.CustomControlSequenceMonitor(connection, "shared-secret",
                                                   r'^create-window$') as mon:
        while True:
            match = await mon.async_get()
            await iterm2.Window.async_create(connection)