Handle VNC reset-dialog in `vnc_click_hack()`
Add TAB + ENTER key presses after the `Ctrl+Alt+<key>` hotkey combo to auto-confirm the "simulate a reset?" dialog that IB gateway sometimes shows. Deats, - press `ISO_Enter` before click to dismiss any prior active dialog window. - add post-hotkey loop sending `Tab` then `KP_Enter` with `asyncio.sleep()` delays to handle the confirmation dialog. - add `asyncio` import. Also, - capture VNC connect error as `vnc_err` and log it instead of falling through to `try_xdo_manual()`. - comment-out `try_xdo_manual()` fallback in VNC error path. - reformat `client.press()` call to multiline style. - reformat `RuntimeError` raise to multiline style with `!r`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codeib_async_CONT
parent
b5a33e1217
commit
44d54babeb
|
|
@ -20,6 +20,7 @@ runnable script-programs.
|
|||
|
||||
'''
|
||||
from __future__ import annotations
|
||||
import asyncio
|
||||
from datetime import ( # noqa
|
||||
datetime,
|
||||
date,
|
||||
|
|
@ -140,7 +141,8 @@ async def data_reset_hack(
|
|||
except (
|
||||
OSError, # no VNC server avail..
|
||||
PermissionError, # asyncvnc pw fail..
|
||||
):
|
||||
) as _vnc_err:
|
||||
vnc_err = _vnc_err
|
||||
try:
|
||||
import i3ipc # noqa (since a deps dynamic check)
|
||||
except ModuleNotFoundError:
|
||||
|
|
@ -166,14 +168,22 @@ async def data_reset_hack(
|
|||
|
||||
# localhost but no vnc-client or it borked..
|
||||
else:
|
||||
try_xdo_manual(client)
|
||||
log.error(
|
||||
'VNC CLICK HACK FAILE with,\n'
|
||||
f'{vnc_err!r}\n'
|
||||
)
|
||||
|
||||
# breakpoint()
|
||||
# try_xdo_manual(client)
|
||||
|
||||
case 'i3ipc_xdotool':
|
||||
try_xdo_manual(client)
|
||||
# i3ipc_xdotool_manual_click_hack()
|
||||
|
||||
case _ as tech:
|
||||
raise RuntimeError(f'{tech} is not supported for reset tech!?')
|
||||
raise RuntimeError(
|
||||
f'{tech!r} is not supported for reset tech!?'
|
||||
)
|
||||
|
||||
# we don't really need the ``xdotool`` approach any more B)
|
||||
return True
|
||||
|
|
@ -269,10 +279,35 @@ async def vnc_click_hack(
|
|||
500,
|
||||
)
|
||||
)
|
||||
# in case a prior dialog win is open/active.
|
||||
await client.press('ISO_Enter')
|
||||
|
||||
# ensure the ib-gw window is active
|
||||
await client.click(MOUSE_BUTTON_LEFT)
|
||||
|
||||
# send the hotkeys combo B)
|
||||
await client.press('Ctrl', 'Alt', key) # keys are stacked
|
||||
await client.press(
|
||||
'Ctrl',
|
||||
'Alt',
|
||||
key,
|
||||
) # NOTE, keys are stacked
|
||||
|
||||
# XXX, sometimes a dialog asking if you want to "simulate
|
||||
# a reset" will show, in which case we want to select
|
||||
# "Yes" (by tabbing) and then hit enter.
|
||||
iters: int = 1
|
||||
delay: float = 0.3
|
||||
await asyncio.sleep(delay)
|
||||
|
||||
for i in range(iters):
|
||||
log.info(f'Sending TAB {i}')
|
||||
await client.press('Tab')
|
||||
await asyncio.sleep(delay)
|
||||
|
||||
for i in range(iters):
|
||||
log.info(f'Sending ENTER {i}')
|
||||
await client.press('KP_Enter')
|
||||
await asyncio.sleep(delay)
|
||||
|
||||
|
||||
def i3ipc_fin_wins_titled(
|
||||
|
|
|
|||
Loading…
Reference in New Issue