made scroll speed code work also with xwayland windows

Murat 2023-10-27 02:26:03 +02:00
parent 4a3763d47c
commit bec1de8439

@ -284,19 +284,29 @@ This script set 6x scroll speed only if app like chromium is focused, require ht
```python
#!/usr/bin/env python
import i3ipc, re
r = re.compile(r'chrom|telegram|Master PDF Editor|typora',re.I)
import i3ipc
scroll_apps = ['discord']
default_speed = 1 # Reading current value would be nice
def on_window_focus(i3, e):
c = e.container.app_id
if not c:
v = default_speed
window_class = getattr(e.container, 'window_class', None)
app_id = getattr(e.container, 'app_id', None)
if window_class:
c = window_class
elif app_id:
c = app_id
else:
return
v = 1
if r.search(c):
v = 6
i3.command(f"input type:pointer scroll_factor {v}")
if c in scroll_apps:
v = 8
i3.command(f'input type:pointer scroll_factor {v}')
i3 = i3ipc.Connection()
i3.on("window::focus", on_window_focus)
i3.on('window::focus', on_window_focus)
i3.main()
```