Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # New and better version -> https://github.com/s4bba7/micetweaks
- #
- #!/usr/bin/env python
- # author: s4bba7
- # ver: 1.1 (updated on 19.06.2016)
- # 1. Install pyudev package: `sudo apt-get install python-pyudev` or from https://github.com/pyudev/pyudev
- # 2. To get the mouseDev you have to run this script first -> http://pastebin.com/TNMYshgz
- # 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).
- mouseDev = "<mouseDev>"
- mouseID = "<mouseID>"
- speed = "0.7"
- deaccel = "1.5"
- import functools
- import os.path
- import pyudev
- import subprocess
- import time
- monitor = pyudev.Monitor.from_netlink(pyudev.Context())
- def setProp(mouseName, speed, deaccel):
- subprocess.call(["xinput", "set-prop", mouseName, "Coordinate Transformation Matrix", speed, "0", "0", "0", speed, "0", "0", "0", deaccel])
- def checkDevs():
- # first time run:
- setProp(mouseID, speed, deaccel)
- for device in iter(monitor.poll, None):
- if str(device)==mouseDev:
- time.sleep(1)
- setProp(mouseID, speed, deaccel)
- # 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.
- def main():
- BASE_PATH = os.path.abspath(os.path.dirname(__file__))
- path = functools.partial(os.path.join, BASE_PATH)
- call = lambda x, *args: subprocess.call([path(x)] + list(args))
- monitor.filter_by(subsystem='usb')
- monitor.start()
- checkDevs()
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment