s4bba7

KDE/plasma 5 automatic mouse plug-in sensitivity fix

Apr 30th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.59 KB | None | 0 0
  1. #
  2. # New and better version -> https://github.com/s4bba7/micetweaks
  3. #
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10. #!/usr/bin/env python
  11. # author: s4bba7
  12. # ver: 1.1 (updated on 19.06.2016)
  13.  
  14. # 1. Install pyudev package: `sudo apt-get install python-pyudev` or from https://github.com/pyudev/pyudev
  15. # 2. To get the mouseDev you have to run this script first -> http://pastebin.com/TNMYshgz
  16. # 3. To get the mouseID execute `xinput --list` and find your device. If there's more than one you should use one of it's IDs (not mouseID).
  17.  
  18. mouseDev = "<mouseDev>"
  19. mouseID = "<mouseID>"
  20. speed = "0.7"
  21. deaccel = "1.5"
  22.  
  23. import functools
  24. import os.path
  25. import pyudev
  26. import subprocess
  27. import time
  28. monitor = pyudev.Monitor.from_netlink(pyudev.Context())
  29.  
  30.  
  31. def setProp(mouseName, speed, deaccel):
  32.     subprocess.call(["xinput", "set-prop", mouseName, "Coordinate Transformation Matrix", speed, "0", "0", "0", speed, "0", "0", "0", deaccel])
  33.  
  34.  
  35. def checkDevs():
  36.     # first time run:
  37.     setProp(mouseID, speed, deaccel)
  38.  
  39.     for device in iter(monitor.poll, None):
  40.         if str(device)==mouseDev:
  41.             time.sleep(1)
  42.             setProp(mouseID, speed, deaccel)
  43.         # you may add more devs here in elif statement. If you do don't forget to add setProp function before this loop into "first time run" section.
  44.  
  45.  
  46. def main():
  47.     BASE_PATH = os.path.abspath(os.path.dirname(__file__))
  48.     path = functools.partial(os.path.join, BASE_PATH)
  49.     call = lambda x, *args: subprocess.call([path(x)] + list(args))
  50.  
  51.     monitor.filter_by(subsystem='usb')
  52.     monitor.start()
  53.     checkDevs()
  54.  
  55.  
  56. if __name__ == '__main__':
  57.     main()
Add Comment
Please, Sign In to add comment