Skip to content

PermissionError: [Errno 13] Failed to open the uinput device: Permission denied #9

@damies13

Description

@damies13

I am trying to use uinput as a standard user, as for my intended usage this is how most people will want to use it.

  • I have installed uinput into a python venv using pip install python-uinput
  • I have run chmod a=rw /dev/input as root (comment from issue I got nothing reaction from the example code #3)
  • I have run /usr/sbin/modprobe -i uinput as the standard user
  • I have confirmed the module is loaded with lsmod | grep uinput, I got: uinput 20480 0

I used the mouse example:

import uinput

with uinput.Device([uinput.REL_X, uinput.REL_Y, uinput.BTN_LEFT, uinput.BTN_RIGHT]) as device:
    for i in range(20):
        device.emit(uinput.REL_X, 5)
        device.emit(uinput.REL_Y, 5)

when running this I get:

Traceback (most recent call last):
  File "/home/dave/Documents/github/robotframework-dbus/tmp/uinput_mouse.py", line 3, in <module>
    with uinput.Device([uinput.REL_X, uinput.REL_Y, uinput.BTN_LEFT, uinput.BTN_RIGHT]) as device:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dave/Documents/github/robotframework-dbus/.venv/lib/python3.11/site-packages/uinput/__init__.py", line 190, in __init__
    self.__uinput_fd = fd or fdopen()
                             ^^^^^^^^
  File "/home/dave/Documents/github/robotframework-dbus/.venv/lib/python3.11/site-packages/uinput/__init__.py", line 88, in fdopen
    return _libsuinput.suinput_open()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dave/Documents/github/robotframework-dbus/.venv/lib/python3.11/site-packages/uinput/__init__.py", line 74, in _open_error_handler
    raise OSError(code, msg)
PermissionError: [Errno 13] Failed to open the uinput device: Permission denied

I tried to check dmesg (also based on comment from Issue #3) but current user is not able to access dmesg (dmesg: read kernel buffer failed: Operation not permitted), I when I checked dmesg as root it on;y shows messages from when I tried to run the same example as root, which also did not move the mouse on the desktop of the current logged in user (not surprising I guess)

I'm not sure how to proceed from here? Any advice? does uinput-python work for non-privileged users?

edit:

  • Debian 12 (bookworm) 64bit
  • Gnome 43.9
  • Wayland (This is why I'm looking into uinput-python, pyautogui doesn't work with Wayland)

Dave.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions