daneah / iterm-components

:computer: Custom status bar components for use with iTerm2
https://www.iterm2.com/3.3/documentation-status-bar.html
MIT License
69 stars 9 forks source link

Access knob values in onclick handler #5

Closed daneah closed 5 years ago

daneah commented 5 years ago

It would be cool for the GitHub stars component to open the configured repo in the browser on click via:

@iterm2.RPC
def click_handler(session_id):
    repo = ...
    proc = await asyncio.create_subprocess_shell(
        f'open https://github.com/{repo}',
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE,
    )
    stdout, stderr = await proc.communicate()

Unfortunately, the repo value is only available in the knobs, which can't be passed to the onclick coroutine. This is perhaps possible with some magic since the @StatusBarRPC coroutine does receive the knobs, but it was out of my reach.

daneah commented 5 years ago

Resolved in #9 / #7