Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Install OS dependencies
run: |
sudo apt-get update -yy
sudo apt-get install -yy --no-install-recommends libcairo2-dev libgirepository-2.0-dev gir1.2-gtk-4.0
sudo apt-get install -yy --no-install-recommends libwayland-dev libcairo2-dev libgirepository-2.0-dev gir1.2-gtk-4.0
- run: uv pip install -r pyproject.toml
- run: uv pip install --group tests
- run: pytest
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ Ensure to meet the following dependencies:
- python3-babel
- python3-croniter
- python3-gi
- python3-psutil
- python3-packaging
- python3-xlib
- python3-pywayland (optional for KDE/other wayland)
Expand Down Expand Up @@ -191,7 +190,6 @@ This method has the same caveats about icons/window icons as running from source
- Smart pause if system is idle
- Multi-screen support
- Customizable user interface
- RPC API to control externally
- Command-line arguments to control the running instance
- Customizable using plug-ins

Expand Down
1 change: 0 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Depends: ${misc:Depends}, ${python3:Depends},
x11-utils,
xprintidle,
alsa-utils,
python3-psutil,
python3-croniter,
python3-packaging,
gir1.2-notify-0.7,
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies = [
"pywayland",
"PyGObject",
"babel",
"psutil",
"packaging",
"python-xlib",
]
Expand Down Expand Up @@ -65,7 +64,6 @@ types = [
"mypy==1.15.0",
"PyGObject-stubs==2.13.0",
"types-croniter==5.0.1.20250322",
"types-psutil==7.0.0.20250218",
"types-python-xlib==0.33.0.20240407",
{include-group = "tests"},
]
Expand Down
124 changes: 3 additions & 121 deletions safeeyes/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,140 +20,22 @@
your eyes from eye strain.
"""

import argparse
import logging
import signal
import sys

import psutil
from safeeyes import utility, translations
from safeeyes.translations import translate as _
from safeeyes import translations
from safeeyes.model import Config
from safeeyes.safeeyes import SafeEyes
from safeeyes.safeeyes import SAFE_EYES_VERSION
from safeeyes.rpc import RPCClient


def __running():
"""Check if SafeEyes is already running."""
process_count = 0
current_user = psutil.Process().username()
for proc in psutil.process_iter():
if not proc.cmdline:
continue
try:
# Check if safeeyes is in process arguments
if callable(proc.cmdline):
# Latest psutil has cmdline function
cmd_line = proc.cmdline()
else:
# In older versions cmdline was a list object
cmd_line = proc.cmdline
if ("python3" in cmd_line[0] or "python" in cmd_line[0]) and (
"safeeyes" in cmd_line[1] or "safeeyes" in cmd_line
):
if proc.username() == current_user:
process_count += 1
if process_count > 1:
return True

# Ignore if process does not exist or does not have command line args
except (IndexError, psutil.NoSuchProcess):
pass
return False


def main():
"""Start the Safe Eyes."""
system_locale = translations.setup()

parser = argparse.ArgumentParser(prog="safeeyes")
group = parser.add_mutually_exclusive_group()
group.add_argument(
"-a", "--about", help=_("show the about dialog"), action="store_true"
)
group.add_argument(
"-d",
"--disable",
help=_("disable the currently running safeeyes instance"),
action="store_true",
)
group.add_argument(
"-e",
"--enable",
help=_("enable the currently running safeeyes instance"),
action="store_true",
)
group.add_argument(
"-q",
"--quit",
help=_("quit the running safeeyes instance and exit"),
action="store_true",
)
group.add_argument(
"-s", "--settings", help=_("show the settings dialog"), action="store_true"
)
group.add_argument(
"-t", "--take-break", help=_("Take a break now").lower(), action="store_true"
)
parser.add_argument(
"--debug", help=_("start safeeyes in debug mode"), action="store_true"
)
parser.add_argument(
"--status",
help=_("print the status of running safeeyes instance and exit"),
action="store_true",
)
parser.add_argument(
"--version", action="version", version="%(prog)s " + SAFE_EYES_VERSION
)
args = parser.parse_args()

# Initialize the logging
utility.initialize_logging(args.debug)
utility.initialize_platform()
config = Config.load()
utility.cleanup_old_user_stylesheet()

if __running():
logging.info("Safe Eyes is already running")
if not config.get("use_rpc_server", True):
# RPC sever is disabled
print(
_(
"Safe Eyes is running without an RPC server. Turn it on to use"
" command-line arguments."
)
)
sys.exit(0)
return
rpc_client = RPCClient(config.get("rpc_port"))
if args.about:
rpc_client.show_about()
elif args.disable:
rpc_client.disable_safeeyes()
elif args.enable:
rpc_client.enable_safeeyes()
elif args.settings:
rpc_client.show_settings()
elif args.take_break:
rpc_client.take_break()
elif args.status:
print(rpc_client.status())
elif args.quit:
rpc_client.quit()
else:
# Default behavior is opening settings
rpc_client.show_settings()
sys.exit(0)
else:
if args.status:
print(_("Safe Eyes is not running"))
sys.exit(0)
elif not args.quit:
logging.info("Starting Safe Eyes")
safe_eyes = SafeEyes(system_locale, config, args)
safe_eyes.start()
safe_eyes = SafeEyes(system_locale, config)
safe_eyes.run(sys.argv)


if __name__ == "__main__":
Expand Down
23 changes: 9 additions & 14 deletions safeeyes/config/locale/ar/LC_MESSAGES/safeeyes.po
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ msgstr "أظهر حالة برنامج safeeyes المشتغل حاليا و أ
msgid "Safe Eyes is not running"
msgstr "SafeEyes لا يعمل"

# RPC not enabled message
msgid ""
"Safe Eyes is running without an RPC server. Turn it on to use command-line "
"arguments."
msgstr "يعمل Safe Eyes الآن دون خادوم RPC. شغِّله لكي تستعمل معطيات سطر الأوامر."

# About dialog
msgid "Close"
msgstr "أغلق"
Expand Down Expand Up @@ -160,14 +154,6 @@ msgstr "مكّن تأخير الاستراحات"
msgid "Persist the internal state"
msgstr "ثبّت الحالة الداخلية"

# Settings dialog
msgid "Use RPC server to receive runtime commands"
msgstr "استعمل خادوم RPC لاستقبال الأوامر في وقت التشغيل"

# Settings dialog
msgid "Without the RPC server, command-line commands may not work"
msgstr "قد لا تعمل أوامر سطر الأوامر من غير خادوم RPC"

# Settings dialog
msgid "Long break interval must be a multiple of short break interval"
msgstr "الاستراحات الطويلة يجب أن تكون من مضاعفات مدة الاستراحات القصيرة"
Expand Down Expand Up @@ -603,6 +589,15 @@ msgstr ""
"تم العثور على ورقة الأنماط القديمة في '%(old)s'، تم تجاهلها. بالنسبة للأنماط "
"المخصصة، قم بإنشاء ورقة أنماط جديدة في '%(new)s' بدلاً من ذلك."

msgid "Customizing the postpone and skip shortcuts does not work on Wayland."
msgstr ""

msgid "Safe Eyes - Error"
msgstr ""

msgid "A required plugin is missing dependencies!"
msgstr ""

# Short break
#~ msgid "Tightly close your eyes"
#~ msgstr "أغلق عينيك بشدّة"
Expand Down
23 changes: 9 additions & 14 deletions safeeyes/config/locale/bg/LC_MESSAGES/safeeyes.po
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ msgstr ""
msgid "Safe Eyes is not running"
msgstr ""

# RPC not enabled message
msgid ""
"Safe Eyes is running without an RPC server. Turn it on to use command-line "
"arguments."
msgstr ""

# About dialog
msgid "Close"
msgstr "Затваряне"
Expand Down Expand Up @@ -158,14 +152,6 @@ msgstr ""
msgid "Persist the internal state"
msgstr ""

# Settings dialog
msgid "Use RPC server to receive runtime commands"
msgstr ""

# Settings dialog
msgid "Without the RPC server, command-line commands may not work"
msgstr ""

# Settings dialog
msgid "Long break interval must be a multiple of short break interval"
msgstr ""
Expand Down Expand Up @@ -583,6 +569,15 @@ msgid ""
"stylesheet in '%(new)s' instead."
msgstr ""

msgid "Customizing the postpone and skip shortcuts does not work on Wayland."
msgstr ""

msgid "Safe Eyes - Error"
msgstr ""

msgid "A required plugin is missing dependencies!"
msgstr ""

# Short break
#~ msgid "Tightly close your eyes"
#~ msgstr "Затворете плътно очи"
23 changes: 9 additions & 14 deletions safeeyes/config/locale/bn/LC_MESSAGES/safeeyes.po
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ msgstr ""
msgid "Safe Eyes is not running"
msgstr "Safe Eyes চলছে না"

# RPC not enabled message
msgid ""
"Safe Eyes is running without an RPC server. Turn it on to use command-line "
"arguments."
msgstr ""

# About dialog
msgid "Close"
msgstr ""
Expand Down Expand Up @@ -158,14 +152,6 @@ msgstr ""
msgid "Persist the internal state"
msgstr ""

# Settings dialog
msgid "Use RPC server to receive runtime commands"
msgstr ""

# Settings dialog
msgid "Without the RPC server, command-line commands may not work"
msgstr ""

# Settings dialog
msgid "Long break interval must be a multiple of short break interval"
msgstr ""
Expand Down Expand Up @@ -582,3 +568,12 @@ msgid ""
"Old stylesheet found at '%(old)s', ignoring. For custom styles, create a new "
"stylesheet in '%(new)s' instead."
msgstr ""

msgid "Customizing the postpone and skip shortcuts does not work on Wayland."
msgstr ""

msgid "Safe Eyes - Error"
msgstr ""

msgid "A required plugin is missing dependencies!"
msgstr ""
28 changes: 9 additions & 19 deletions safeeyes/config/locale/ca/LC_MESSAGES/safeeyes.po
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@ msgstr "Mostra l'estat de la instància de safeeyes en funcionament i surt"
msgid "Safe Eyes is not running"
msgstr "Safe Eyes no s'està executant"

# RPC not enabled message
msgid ""
"Safe Eyes is running without an RPC server. Turn it on to use command-line "
"arguments."
msgstr ""
"Safe Eyes s'està executant sense un servidor RPC. Engegueu-lo per usar els "
"arguments de la línia d'ordres."

# About dialog
msgid "Close"
msgstr "Tanca"
Expand Down Expand Up @@ -163,17 +155,6 @@ msgstr "Permet posposar les pauses"
msgid "Persist the internal state"
msgstr "Persisteix l'estat intern"

# Settings dialog
msgid "Use RPC server to receive runtime commands"
msgstr ""
"Empra el servidor RPC per a rebre els comandaments del temps d'execució"

# Settings dialog
msgid "Without the RPC server, command-line commands may not work"
msgstr ""
"Sense el servidor RPC, és possible que les ordres a la línia d'ordres no "
"funcionin"

# Settings dialog
msgid "Long break interval must be a multiple of short break interval"
msgstr ""
Expand Down Expand Up @@ -602,6 +583,15 @@ msgid ""
"stylesheet in '%(new)s' instead."
msgstr ""

msgid "Customizing the postpone and skip shortcuts does not work on Wayland."
msgstr ""

msgid "Safe Eyes - Error"
msgstr ""

msgid "A required plugin is missing dependencies!"
msgstr ""

# Short break
#~ msgid "Tightly close your eyes"
#~ msgstr "Tanqueu fortament els ulls"
Loading