2021-09-23 15:57:07 +00:00
|
|
|
# piker: trading gear for hackers
|
|
|
|
# Copyright (C) Tyler Goodlet (in stewardship for piker0)
|
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
'''
|
|
|
|
IB api client data feed reset hack for i3.
|
|
|
|
|
|
|
|
'''
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
import i3ipc
|
|
|
|
|
|
|
|
i3 = i3ipc.Connection()
|
|
|
|
t = i3.get_tree()
|
|
|
|
|
|
|
|
# for tws
|
|
|
|
win_name = 'Interactive Brokers' # what for gw tho?
|
|
|
|
con = t.find_named(win_name)[0]
|
|
|
|
|
2021-09-23 17:26:47 +00:00
|
|
|
win_id = str(con.window)
|
2021-09-24 15:13:30 +00:00
|
|
|
w, h = con.rect.width, con.rect.height
|
2021-09-23 15:57:07 +00:00
|
|
|
|
|
|
|
# TODO: seems to be a few libs for python but not sure
|
|
|
|
# if they support all the sub commands we need, order of
|
|
|
|
# most recent commit history:
|
|
|
|
# https://github.com/rr-/pyxdotool
|
|
|
|
# https://github.com/ShaneHutter/pyxdotool
|
|
|
|
# https://github.com/cphyc/pyxdotool
|
2021-09-23 17:26:47 +00:00
|
|
|
subprocess.call([
|
|
|
|
'xdotool',
|
2021-09-24 15:13:30 +00:00
|
|
|
'windowactivate', '--sync', win_id,
|
|
|
|
|
2021-09-23 17:26:47 +00:00
|
|
|
# move mouse to bottom left of window (where there should
|
|
|
|
# be nothing to click).
|
2021-09-24 15:13:30 +00:00
|
|
|
'mousemove_relative', '--sync', str(w-3), str(h-3),
|
2021-09-23 17:26:47 +00:00
|
|
|
|
|
|
|
# NOTE: we may need to stick a `--retry 3` in here..
|
2021-09-24 15:13:30 +00:00
|
|
|
'click', '--window', win_id, '1',
|
2021-09-23 17:26:47 +00:00
|
|
|
|
|
|
|
# hackzorzes
|
|
|
|
'key', 'ctrl+alt+f',
|
|
|
|
])
|