|
24 | 24 |
|
25 | 25 | import tractor |
26 | 26 |
|
| 27 | +from piker.log import get_logger |
| 28 | + |
| 29 | +log = get_logger(__name__) |
| 30 | + |
27 | 31 |
|
28 | 32 | _reset_tech: Literal[ |
29 | 33 | 'vnc', |
@@ -134,54 +138,54 @@ def i3ipc_xdotool_manual_click_hack() -> None: |
134 | 138 | # 'IB', # gw running in i3 (newer version?) |
135 | 139 | ] |
136 | 140 |
|
137 | | - for name in win_names: |
138 | | - results = t.find_titled(name) |
139 | | - print(f'results for {name}: {results}') |
140 | | - if results: |
141 | | - con = results[0] |
142 | | - print(f'Resetting data feed for {name}') |
143 | | - win_id = str(con.window) |
144 | | - w, h = con.rect.width, con.rect.height |
145 | | - |
146 | | - # TODO: seems to be a few libs for python but not sure |
147 | | - # if they support all the sub commands we need, order of |
148 | | - # most recent commit history: |
149 | | - # https://github.com/rr-/pyxdotool |
150 | | - # https://github.com/ShaneHutter/pyxdotool |
151 | | - # https://github.com/cphyc/pyxdotool |
152 | | - |
153 | | - # TODO: only run the reconnect (2nd) kc on a detected |
154 | | - # disconnect? |
155 | | - for key_combo, timeout in [ |
156 | | - # only required if we need a connection reset. |
157 | | - # ('ctrl+alt+r', 12), |
158 | | - # data feed reset. |
159 | | - ('ctrl+alt+f', 6) |
160 | | - ]: |
161 | | - subprocess.call([ |
162 | | - 'xdotool', |
163 | | - 'windowactivate', '--sync', win_id, |
164 | | - |
165 | | - # move mouse to bottom left of window (where there should |
166 | | - # be nothing to click). |
167 | | - 'mousemove_relative', '--sync', str(w-4), str(h-4), |
168 | | - |
169 | | - # NOTE: we may need to stick a `--retry 3` in here.. |
170 | | - 'click', '--window', win_id, |
171 | | - '--repeat', '3', '1', |
172 | | - |
173 | | - # hackzorzes |
174 | | - 'key', key_combo, |
175 | | - ], |
176 | | - timeout=timeout, |
177 | | - ) |
| 141 | + try: |
| 142 | + for name in win_names: |
| 143 | + results = t.find_titled(name) |
| 144 | + print(f'results for {name}: {results}') |
| 145 | + if results: |
| 146 | + con = results[0] |
| 147 | + print(f'Resetting data feed for {name}') |
| 148 | + win_id = str(con.window) |
| 149 | + w, h = con.rect.width, con.rect.height |
| 150 | + |
| 151 | + # TODO: seems to be a few libs for python but not sure |
| 152 | + # if they support all the sub commands we need, order of |
| 153 | + # most recent commit history: |
| 154 | + # https://github.com/rr-/pyxdotool |
| 155 | + # https://github.com/ShaneHutter/pyxdotool |
| 156 | + # https://github.com/cphyc/pyxdotool |
| 157 | + |
| 158 | + # TODO: only run the reconnect (2nd) kc on a detected |
| 159 | + # disconnect? |
| 160 | + for key_combo, timeout in [ |
| 161 | + # only required if we need a connection reset. |
| 162 | + # ('ctrl+alt+r', 12), |
| 163 | + # data feed reset. |
| 164 | + ('ctrl+alt+f', 6) |
| 165 | + ]: |
| 166 | + subprocess.call([ |
| 167 | + 'xdotool', |
| 168 | + 'windowactivate', '--sync', win_id, |
| 169 | + |
| 170 | + # move mouse to bottom left of window (where |
| 171 | + # there should be nothing to click). |
| 172 | + 'mousemove_relative', '--sync', str(w-4), str(h-4), |
| 173 | + |
| 174 | + # NOTE: we may need to stick a `--retry 3` in here.. |
| 175 | + 'click', '--window', win_id, |
| 176 | + '--repeat', '3', '1', |
| 177 | + |
| 178 | + # hackzorzes |
| 179 | + 'key', key_combo, |
| 180 | + ], |
| 181 | + timeout=timeout, |
| 182 | + ) |
178 | 183 |
|
179 | 184 | # re-activate and focus original window |
180 | | - try: |
181 | 185 | subprocess.call([ |
182 | 186 | 'xdotool', |
183 | 187 | 'windowactivate', '--sync', str(orig_win_id), |
184 | 188 | 'click', '--window', str(orig_win_id), '1', |
185 | 189 | ]) |
186 | 190 | except subprocess.TimeoutExpired: |
187 | | - log.exception(f'xdotool timed out?') |
| 191 | + log.exception('xdotool timed out?') |
0 commit comments