26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
import subprocess
|
|
import time
|
|
|
|
firefox_mode = False
|
|
|
|
while True:
|
|
result = subprocess.run(['kdotool', 'getmouselocation'], stdout=subprocess.PIPE)
|
|
pointed_window = str(result.stdout).split("window:{")[1].split("}")[0]
|
|
|
|
result = subprocess.run(['qdbus', 'org.kde.KWin', '/KWin', 'org.kde.KWin.getWindowInfo', pointed_window],
|
|
stdout=subprocess.PIPE)
|
|
window_info = str(result.stdout)
|
|
window_title = window_info.split("resourceName: ")[1].split("\\n")[0]
|
|
|
|
if not firefox_mode and window_title == "firefox":
|
|
subprocess.run(
|
|
'dbus-send --type=method_call --dest=org.kde.KWin /org/kde/KWin/InputDevice/event11 org.freedesktop.DBus.Properties.Set string:"org.kde.KWin.InputDevice" string:"scrollFactor" variant:double:1',
|
|
shell=True)
|
|
firefox_mode = True
|
|
elif firefox_mode and window_title != "firefox":
|
|
subprocess.run(
|
|
'dbus-send --type=method_call --dest=org.kde.KWin /org/kde/KWin/InputDevice/event11 org.freedesktop.DBus.Properties.Set string:"org.kde.KWin.InputDevice" string:"scrollFactor" variant:double:0.1',
|
|
shell=True)
|
|
firefox_mode = False
|
|
|
|
time.sleep(0.5)
|