slgobinath / SafeEyes

Protect your eyes from eye strain using this simple and beautiful, yet extensible break reminder
http://slgobinath.github.io/SafeEyes/
GNU General Public License v3.0
1.45k stars 163 forks source link

Smartpause: add support for ext-idle-notify-v1 using pywayland #576

Open deltragon opened 4 months ago

deltragon commented 4 months ago

Fixes https://github.com/slgobinath/SafeEyes/issues/391.

This is an alternative to https://github.com/slgobinath/SafeEyes/pull/553. Instead of relying on swayidle, which appears to have issues both on KDE as well as within Flatpaks, this PR uses pywayland to use the ext-idle-notify-v1 wayland protocol directly.

Tested on KDE Plasma 6.0 Wayland. This still needs to be tested on compositors that do not implement the ext-idle-notify-v1 protocol. According to this, this would be Weston, Mir or GameScope. (Gnome still has its own solution.) The plugin will not work correctly on these compositors, but we should probably give a better error.

deltragon commented 2 months ago

I've tested this on the bigger desktops, no issues. I did manage to test this on Weston - smartpause simply silently doesn't work, as without this change.

This is ready to merge.

deltragon commented 2 months ago

(Note that I had this previously marked as waiting on https://github.com/slgobinath/SafeEyes/pull/561 - I since managed to work around that.)

archisman-panigrahi commented 2 months ago

Is there any dependency I need to install to test this? Also, will this still work on xorg (with xprintidle) after merging this?

deltragon commented 2 months ago

@archisman-panigrahi Yes, xprintidle will still work - this is only used on wayland (not gnome and not sway, since they have their own implementation). Regarding dependencies - this does need pywayland, which I did add to the setup.py. However, it seems that pywayland is not packaged for debian, so I cannot simply add it to debian/control... What is the process for requesting a package from debian? Or would we need to add it to our ppa?

archisman-panigrahi commented 2 months ago

What is the process for requesting a package from debian? Or would we need to add it to our ppa?

To request a package to Debian, one needs to file a bug report in the wnpp list https://www.debian.org/devel/wnpp/. Hopefully someone will package it, but it may take a while. Sending them a packaged version helps to speed up the process. I will try that. However, I am not very familiar with the process of official debian submission.

However, I can add it to the PPA. Most packages in pypi can be easily debianized.

archisman-panigrahi commented 2 months ago

Here is the debian bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1076337

Now I need to figure out how to package it

archisman-panigrahi commented 2 months ago

I stabilized the builds of python3-pywayland (I have not tested them, though). They are hosted in the safeeyes daily builds ppa https://code.launchpad.net/~safeeyes-team/+archive/ubuntu/safeeyes-daily

The .deb packages can be directly downloaded from here https://code.launchpad.net/~safeeyes-team/+archive/ubuntu/safeeyes-daily

archisman-panigrahi commented 2 months ago

Are #561 and #576 independent of each other? I will be happy to test this in Ubuntu with my experimental pywayland package (which itself is untested), but I want to merge this only after pywayland is in debian, which may take a few months.

deltragon commented 2 months ago

@archisman-panigrahi Yes, this is independent of #561 (and vice versa). In theory, we can make pywayland not a hard dependency on wayland, and fall back on xprintidle if it exists. That would make it work on environments where it is available already (eg. on Arch, and for people using the PPA), and keep everything the same everywhere else.

Levi-Lesches commented 1 month ago

Hi, I have a question about using this protocol on my own project. I tested on a few devices, and ext-idle-notify is not present on all Wayland devices. Notably, it was present on KDE + Wayland, but not on Gnome + Wayland. Further investigation revealed that the protocol is still in the "staging" phase, which is basically the pre-release phase. I am using a similar approach using libxcb on X11 and ext-idle-notify on Wayland, but I'm not sure what to do about these devices that use Wayland but not the protocol.

Have you guys run into such issues? And if so, do you have any workarounds you'd recommend? The only solution I can think of now is to wait for the protocol to be implemented on those devices.

deltragon commented 1 month ago

@Levi-Lesches You're right that ext-idle-notify is not implemented on GNOME+Wayland. For that configuration, we're using a Mutter-specific dbus call: https://github.com/slgobinath/SafeEyes/blob/003812cb96551b03c2b0322baf34ca826f9d0dc8/safeeyes/plugins/smartpause/plugin.py#L91-L110 For other compositors such as Weston, Mir or Gamescope that implement Wayland but not ext-idle-notify, we're also out of luck.

Levi-Lesches commented 1 month ago

Ok, good to know it's not just me. I'm going to leave my implementation as-is and call it "future proof", since as time goes on, more Wayland setups will hopefully support it