mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 07:51:28 +00:00
made scroll speed code work also with xwayland windows
parent
4a3763d47c
commit
bec1de8439
28
Tricks.md
28
Tricks.md
|
@ -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()
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue