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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4

[*.{py}]
trim_trailing_whitespace = true
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Use `git config blame.ignorerevsfile .git-blame-ignore-revs` to make `git blame` ignore the following commits.

# format using ruff
5bac6fe9a3b9b95abbbb364a48b5aad7c915e4ed
12 changes: 12 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint

on: [push, pull_request]

jobs:
lint-ruff:
runs-on: ubuntu-latest
name: ruff
steps:
- name: Check out source repository
uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
11 changes: 6 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ jobs:
pip install build wheel

- name: Get Current Version
run: |
project_version=$(python3 setup.py --version)
echo "project_version=$project_version" >> $GITHUB_OUTPUT
uses: SebRollen/[email protected]
with:
file: "pyproject.toml"
field: project.version
id: get_current_version

- name: Create Tag
uses: mathieudutour/[email protected]
with:
custom_tag: "${{steps.get_current_version.outputs.project_version}}"
custom_tag: "${{steps.get_current_version.outputs.value}}"
github_token: ${{ secrets.GH_API_SECRET }}

- name: Build Changelog
Expand All @@ -44,7 +45,7 @@ jobs:
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: 'v${{steps.get_current_version.outputs.project_version}}'
tag_name: 'v${{steps.get_current_version.outputs.value}}'
body: ${{steps.build_changelog.outputs.changelog}}
token: ${{ secrets.GH_API_SECRET }}

Expand Down
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
include LICENSES/GPL-3.0-or-later.txt
include README.md

graft safeeyes

global-exclude *.py[cod]
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,8 @@ To ensure the new strings are well-formed, you can use `python validate_po.py --
1. Checkout the latest commits from the `master` branch
2. Run `python3 -m safeeyes` to make sure nothing is broken
3. Update the Safe Eyes version in the following places (Open the project in VSCode and search for the current version):
- [setup.py](https://github.com/slgobinath/SafeEyes/blob/master/setup.py#L82)
- [setup.py](https://github.com/slgobinath/SafeEyes/blob/master/setup.py#L89)
- [safeeyes.py](https://github.com/slgobinath/SafeEyes/blob/master/safeeyes/safeeyes.py#L42)
- [pyproject.toml](https://github.com/slgobinath/SafeEyes/blob/master/pyproject.toml#L4)
- [pyproject.toml](https://github.com/slgobinath/SafeEyes/blob/master/pyproject.toml#L35)
- [io.github.slgobinath.SafeEyes.metainfo.xml](https://github.com/slgobinath/SafeEyes/blob/master/safeeyes/platform/io.github.slgobinath.SafeEyes.metainfo.xml#L56)
- [about_dialog.glade](https://github.com/slgobinath/SafeEyes/blob/master/safeeyes/glade/about_dialog.glade#L74)
4. Update the [changelog](https://github.com/slgobinath/SafeEyes/blob/master/debian/changelog) (for Ubuntu PPA release)
Expand Down
48 changes: 48 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[project]
name = "safeeyes"
version = "2.2.3"
description = "Protect your eyes from eye strain using this continuous breaks reminder."
keywords = ["linux utility health eye-strain safe-eyes"]
readme = "README.md"
authors = [
{name = "Gobinath Loganathan", email = "[email protected]"},
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: X11 Applications :: GTK",
"Environment :: Other Environment",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Utilities",
]
dependencies = [
"pywayland",
"PyGObject",
"babel",
"psutil",
"packaging",
"python-xlib",
]
requires-python = ">=3.10"

[project.urls]
Homepage = "https://github.com/slgobinath/SafeEyes"
Downloads = "https://github.com/slgobinath/SafeEyes/archive/v2.2.3.tar.gz"

[project.scripts]
safeeyes = "safeeyes.__main__:main"

[project.optional-dependencies]
healthstats = ["croniter"]

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
include=["safeeyes*"]
17 changes: 17 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
target-version = "py310"

# gettext
builtins = ["_"]

[lint]
select = ["E", "W", "F", "D2", "D3", "D4"]
ignore = [
# PyGObject needs require_version before imports
"E402",

# these are disabled for now, but should probably be cleaned up at some point
"D205", "D401", "D404",
]

[lint.pydocstyle]
convention = "numpy"
98 changes: 69 additions & 29 deletions safeeyes/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Safe Eyes is a utility to remind you to take break frequently to protect
your eyes from eye strain.
"""
Safe Eyes is a utility to remind you to take break frequently to protect your eyes from eye strain.
"""

import argparse
import gettext
import locale
Expand All @@ -33,13 +34,11 @@
from safeeyes.safeeyes import SAFE_EYES_VERSION
from safeeyes.rpc import RPCClient

gettext.install('safeeyes', utility.LOCALE_PATH)
gettext.install("safeeyes", utility.LOCALE_PATH)


def __running():
"""
Check if SafeEyes is already running.
"""
"""Check if SafeEyes is already running."""
process_count = 0
for proc in psutil.process_iter():
if not proc.cmdline:
Expand All @@ -52,7 +51,9 @@ def __running():
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 ("python3" in cmd_line[0] or "python" in cmd_line[0]) and (
"safeeyes" in cmd_line[1] or "safeeyes" in cmd_line
):
process_count += 1
if process_count > 1:
return True
Expand All @@ -64,29 +65,63 @@ def __running():


def main():
"""
Start the Safe Eyes.
"""
system_locale = gettext.translation('safeeyes', localedir=utility.LOCALE_PATH, languages=[utility.system_locale(), 'en_US'], fallback=True)
"""Start the Safe Eyes."""
system_locale = gettext.translation(
"safeeyes",
localedir=utility.LOCALE_PATH,
languages=[utility.system_locale(), "en_US"],
fallback=True,
)
system_locale.install()
try:
# locale.bindtextdomain is required for Glade files
locale.bindtextdomain('safeeyes', utility.LOCALE_PATH)
locale.bindtextdomain("safeeyes", utility.LOCALE_PATH)
except AttributeError:
logging.warning('installed python\'s gettext module does not support locale.bindtextdomain. locale.bindtextdomain is required for Glade files')

logging.warning(
"installed python's gettext module does not support locale.bindtextdomain."
" locale.bindtextdomain is required for Glade files"
)

parser = argparse.ArgumentParser(prog='safeeyes')
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)
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
Expand All @@ -99,10 +134,15 @@ def main():
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.'))
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'))
rpc_client = RPCClient(config.get("rpc_port"))
if args.about:
rpc_client.show_about()
elif args.disable:
Expand All @@ -123,14 +163,14 @@ def main():
sys.exit(0)
else:
if args.status:
print(_('Safe Eyes is not running'))
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()


if __name__ == '__main__':
signal.signal(signal.SIGINT, signal.SIG_DFL) # Handle Ctrl + C
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal.SIG_DFL) # Handle Ctrl + C
main()
Loading