Ejemplo n.º 1
0
    def update_hooks(pid_file, pids):
        pids = ' '.join(pids)
        command = command_template + pids

        pid_file.seek(0)
        pid_file.truncate()
        pid_file.write(pids)
        pid_file.flush()

        for event in events:
            if pids:
                tmux_util.register_hook(event, command)
            else:
                tmux_util.unregister_hook(event)
Ejemplo n.º 2
0
def setup_tmux_hooks():
    """Registers tmux hooks which are
    required to notice a change in the visibility
    of the pane this program runs in.
    Also it's required to notice new tmux clients
    displaying our pane.

    Returns:
        function which unregisters the registered hooks
    """
    events = ('client-session-changed', 'session-window-changed',
              'pane-mode-changed')
    command = 'kill -USR1 ' + str(os.getpid())

    for event in events:
        tmux_util.register_hook(event, command)

    def remove_hooks():
        """Removes the hooks registered by the outer function."""
        for event in events:
            tmux_util.unregister_hook(event)

    return remove_hooks