Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smartpause: use X API instead of xprintidle subprocess #358

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ sudo emerge -av x11-misc/safeeyes
### Debian

```bash
sudo apt-get install gir1.2-appindicator3-0.1 gir1.2-notify-0.7 python3-psutil python3-xlib xprintidle python3-pip
sudo apt-get install gir1.2-appindicator3-0.1 gir1.2-notify-0.7 python3-psutil python3-xlib python3-xcffib python3-pip
sudo pip3 install safeeyes
sudo update-icon-caches /usr/share/icons/hicolor
```
Expand All @@ -72,7 +72,7 @@ sudo apt-get install safeeyes
### Fedora

```bash
sudo dnf install libappindicator-gtk3 python3-psutil cairo-devel python3-devel gobject-introspection-devel cairo-gobject-devel
sudo dnf install libappindicator-gtk3 python3-psutil cairo-devel python3-devel gobject-introspection-devel cairo-gobject-devel python-xcffib
sudo pip3 install safeeyes
sudo gtk-update-icon-cache /usr/share/icons/hicolor
```
Expand All @@ -85,7 +85,7 @@ Ensure to meet the following dependencies:
- gir1.2-notify-0.7
- libappindicator-gtk3
- python3-psutil
- xprintidle (optional)
- python3-xcffib

**To install Safe Eyes:**

Expand Down Expand Up @@ -113,7 +113,7 @@ Some Linux systems like Cent OS do not have matching dependencies available in t
1. Install the necessary dependencies

```
sudo yum install dbus dbus-devel cairo cairo-devel cairomm-devel libjpeg-turbo-devel pango pango-devel pangomm pangomm-devel
sudo yum install dbus dbus-devel cairo cairo-devel cairomm-devel libjpeg-turbo-devel pango pango-devel pangomm pangomm-devel libxcb-devel
```

2. Create a virtual environment in your home folder
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Homepage: https://github.com/slgobinath/SafeEyes/

Package: safeeyes
Architecture: all
Depends: ${misc:Depends}, ${python3:Depends}, gir1.2-appindicator3-0.1, python3 (>= 3.4.0), python3-xlib, python3-dbus, gir1.2-notify-0.7, python3-babel, x11-utils, xprintidle, alsa-utils, python3-psutil
Depends: ${misc:Depends}, ${python3:Depends}, gir1.2-appindicator3-0.1, python3 (>= 3.4.0), python3-xlib, python3-dbus, gir1.2-notify-0.7, python3-babel, x11-utils, python3-xcffib, alsa-utils, python3-psutil
Description: Safe Eyes
Safe Eyes is a simple tool to remind you to take periodic breaks for your eyes. This is essential for anyone spending more time on the computer to avoid eye strain and other physical problems.
.
Expand Down
11 changes: 4 additions & 7 deletions safeeyes/plugins/smartpause/dependency_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@


def validate(plugin_config):
command = None
if Utility.DESKTOP_ENVIRONMENT == "gnome" and Utility.IS_WAYLAND:
command = "dbus-send"
else:
command = "xprintidle"
if not Utility.command_exist(command):
return _("Please install the command-line tool '%s'") % command
else:
return None
if not Utility.command_exist(command):
return _("Please install the command-line tool '%s'") % command

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we try to make the xcffib dependency optional, by putting an import check here?
Or keep it simple and not have maybe-dependencies for bundled components?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can Smart Pause plugin work without the xcffib library? If it cannot please add a check here. This check will only disable the plugin (not Safe Eyes) if the dependency is missing.

return None
25 changes: 25 additions & 0 deletions safeeyes/plugins/smartpause/interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from abc import ABC, abstractmethod
from numbers import Integral


class IdleTimeInterface(ABC):
"""Tells how long the user has been idle."""
# This could be a typing.Protocol in Python 3.8.

@classmethod
@abstractmethod
def is_applicable(cls, context) -> bool:
"""Is this implementation usable in this context?"""
pass

@abstractmethod
def idle_seconds(self) -> Integral:
"""Time since last user input, in seconds.

Returns 0 on failure."""
pass

@abstractmethod
def destroy(self) -> None:
"""Destroy this checker (clean up any resources)."""
pass
Loading