{"action":"created","issue":{"url":"https://api.github.com/repos/gvalkov/python-evdev/issues/35","labels_url":"https://api.github.com/repos/gvalkov/python-evdev/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/gvalkov/python-evdev/issues/35/comments","events_url":"https://api.github.com/repos/gvalkov/python-evdev/issues/35/events","html_url":"https://github.com/gvalkov/python-evdev/issues/35","id":85912251,"number":35,"title":"Read-only opening of devices","user":{"login":"sim642","id":378740,"avatar_url":"https://avatars.githubusercontent.com/u/378740?v=3","gravatar_id":"","url":"https://api.github.com/users/sim642","html_url":"https://github.com/sim642","followers_url":"https://api.github.com/users/sim642/followers","following_url":"https://api.github.com/users/sim642/following{/other_user}","gists_url":"https://api.github.com/users/sim642/gists{/gist_id}","starred_url":"https://api.github.com/users/sim642/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sim642/subscriptions","organizations_url":"https://api.github.com/users/sim642/orgs","repos_url":"https://api.github.com/users/sim642/repos","events_url":"https://api.github.com/users/sim642/events{/privacy}","received_events_url":"https://api.github.com/users/sim642/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-07T15:42:09Z","updated_at":"2015-06-16T18:12:40Z","closed_at":"2015-06-16T18:12:40Z","body":"Currently InputDevice wants to open the device `os.RDWR` ([code](https://github.com/gvalkov/python-evdev/blob/master/evdev/device.py#L93)) but there's good reason to be able to open a device `os.RDONLY`, either if there's no intention to modify anything or there's not sufficient permissions.\r\n\r\nMaking a custom derived class with changed `__init__` seems to work but I think it could very well be included in the library:\r\n```py\r\nfrom evdev import InputDevice, _input, DeviceInfo\r\nimport os\r\n\r\nclass ReadInputDevice(InputDevice):\r\n\tdef __init__(self, dev):\r\n\t\t'''\r\n\t\t:param dev: path to input device\r\n\t\t'''\r\n\r\n\t\t#: Path to input device.\r\n\t\tself.fn = dev\r\n\r\n\t\t#: A non-blocking file descriptor to the device file.\r\n\t\tself.fd = os.open(dev, os.O_RDONLY | os.O_NONBLOCK)\r\n\r\n\t\t# Returns (bustype, vendor, product, version, name, phys, capabilities).\r\n\t\tinfo_res = _input.ioctl_devinfo(self.fd)\r\n\r\n\t\t#: A :class:`DeviceInfo <evdev.device.DeviceInfo>` instance.\r\n\t\tself.info = DeviceInfo(*info_res[:4])\r\n\r\n\t\t#: The name of the event device.\r\n\t\tself.name = info_res[4]\r\n\r\n\t\t#: The physical topology of the device.\r\n\t\tself.phys = info_res[5]\r\n\r\n\t\t#: The evdev protocol version.\r\n\t\tself.version = _input.ioctl_EVIOCGVERSION(self.fd)\r\n\r\n\t\t#: The raw dictionary of device capabilities - see `:func:capabilities()`.\r\n\t\tself._rawcapabilities = _input.ioctl_capabilities(self.fd)\r\n\r\n\t\t#: The number of force feedback effects the device can keep in its memory.\r\n\t\tself.ff_effects_count = _input.ioctl_EVIOCGEFFECTS(self.fd)\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/gvalkov/python-evdev/issues/comments/112518042","html_url":"https://github.com/gvalkov/python-evdev/issues/35#issuecomment-112518042","issue_url":"https://api.github.com/repos/gvalkov/python-evdev/issues/35","id":112518042,"user":{"login":"gvalkov","id":190997,"avatar_url":"https://avatars.githubusercontent.com/u/190997?v=3","gravatar_id":"","url":"https://api.github.com/users/gvalkov","html_url":"https://github.com/gvalkov","followers_url":"https://api.github.com/users/gvalkov/followers","following_url":"https://api.github.com/users/gvalkov/following{/other_user}","gists_url":"https://api.github.com/users/gvalkov/gists{/gist_id}","starred_url":"https://api.github.com/users/gvalkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvalkov/subscriptions","organizations_url":"https://api.github.com/users/gvalkov/orgs","repos_url":"https://api.github.com/users/gvalkov/repos","events_url":"https://api.github.com/users/gvalkov/events{/privacy}","received_events_url":"https://api.github.com/users/gvalkov/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T18:12:40Z","updated_at":"2015-06-16T18:12:40Z","body":"Appologies for the delay. Fixed in 4051ba9c7c731566b33251aed149f103aa8f7256 and available in `evdev>=0.5.0`. "}}