carrot69 / keep-presence

Keeps your computer awake by moving the mouse or pressing a key when you step away.
Creative Commons Zero v1.0 Universal
246 stars 38 forks source link

Doesn't work on Wayland only XOrg #2

Open YusufMavzer opened 3 years ago

YusufMavzer commented 3 years ago

Fedora 34 uses wayland and this one doesn't work on it

alphamarket commented 2 years ago

Hey there... Are you going to do something to fix this issue?

YusufMavzer commented 2 years ago

I'm not the one that implemented this but I can create a fix if you want

YusufMavzer commented 2 years ago

an update. We'll have to wait for this to be closed https://github.com/moses-palmer/pynput/issues/331

carrot69 commented 2 years ago

Indeed, keep-presence uses pynput who is currently having issues as well with Wayland. Once they fix it, we should be fine!

Anyway, if someone finds a bugfix, please create a PR or tell me and I'll submit the changes.

austinsr1 commented 2 years ago

This might not be ideal, since it requires sudo/root to move the mouse, but evemu-event does work. Example that I found on an ask ubuntu thread: sudo evemu-event /dev/input/event5 --type EV_REL --code REL_X --value 50 sudo evemu-event /dev/input/event5 --type EV_REL --code REL_Y --value 50 sudo evemu-event /dev/input/event5 --type EV_KEY --code BTN_RIGHT --value 1 sudo evemu-event /dev/input/event5 --type EV_KEY --code BTN_RIGHT --value 0

Added the X and Y move commands into the is_user_away: function and its up and going again.

shadeep commented 1 year ago

I get the following error when running keep-presence with Wayland on Fedora 37.

Traceback (most recent call last):
  File "/snap/keep-presence/96/keep-presence.py", line 6, in <module>
    from pynput.mouse import Controller as MouseController
  File "/snap/keep-presence/96/lib/python3.6/site-packages/pynput/__init__.py", line 40, in <module>
    from . import keyboard
  File "/snap/keep-presence/96/lib/python3.6/site-packages/pynput/keyboard/__init__.py", line 31, in <module>
    backend = backend(__name__)
  File "/snap/keep-presence/96/lib/python3.6/site-packages/pynput/_util/__init__.py", line 82, in backend
    if resolutions else '')
ImportError: this platform is not supported: ('failed to acquire X connection: Can\'t connect to display ":0": b\'Authorization required, but no authorization protocol specified\\n\'', DisplayConnectionError(':0', b'Authorization required, but no authorization protocol specified\n'))

Stumbled across this while looking for a solution. Running the following solves the authorization issue: xhost si:localuser:<user-id>

See: https://stackoverflow.com/questions/48833451/no-protocol-specified-when-running-a-sudo-su-app-on-ubuntu-linux

suncoastkid commented 7 months ago

Is this project dead? Still seeing this issue open from two year ago and having the same issue with it not working on Wayland.

carrot69 commented 7 months ago

an update. We'll have to wait for this to be closed moses-palmer/pynput#331

@suncoastkid keep-presence uses the pynput library, we have to wait for pynput to fix the problem.

https://pynput.readthedocs.io/en/latest/limitations.html?highlight=wayland#linux