From e28d9b4afae4afe27b0721426833e685d814ea63 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Mon, 13 May 2024 02:09:03 +0200 Subject: [PATCH] initial commit --- .idea/.gitignore | 8 ++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ .idea/misc.xml | 7 +++++ .idea/modules.xml | 8 ++++++ .idea/plasma-mxmaster-fix.iml | 10 +++++++ install.sh | 3 +++ plasma-mxmaster-fix.py | 26 +++++++++++++++++++ plasma-mxmaster-fix.service | 11 ++++++++ 8 files changed, 79 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/plasma-mxmaster-fix.iml create mode 100755 install.sh create mode 100644 plasma-mxmaster-fix.py create mode 100644 plasma-mxmaster-fix.service diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8ad399a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..236a317 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/plasma-mxmaster-fix.iml b/.idea/plasma-mxmaster-fix.iml new file mode 100644 index 0000000..2c80e12 --- /dev/null +++ b/.idea/plasma-mxmaster-fix.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..0e35ccb --- /dev/null +++ b/install.sh @@ -0,0 +1,3 @@ +mkdir /opt/plasma-mxmaster-fix +cp plasma-mxmaster-fix.py /opt/plasma-mxmaster-fix/plasma-mxmaster-fix.py +cp plasma-mxmaster-fix.service /etc/systemd/user/plasma-mxmaster-fix.service \ No newline at end of file diff --git a/plasma-mxmaster-fix.py b/plasma-mxmaster-fix.py new file mode 100644 index 0000000..87f3ab7 --- /dev/null +++ b/plasma-mxmaster-fix.py @@ -0,0 +1,26 @@ +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) diff --git a/plasma-mxmaster-fix.service b/plasma-mxmaster-fix.service new file mode 100644 index 0000000..0ebc3eb --- /dev/null +++ b/plasma-mxmaster-fix.service @@ -0,0 +1,11 @@ +[Unit] +Description=Plasma MX Master 3S fix +After=multi-user.target + +[Service] +Type=simple +Restart=always +ExecStart=/usr/bin/python3 /opt/plasma-mxmaster-fix/plasma-mxmaster-fix.py + +[Install] +WantedBy=multi-user.target \ No newline at end of file