From bcecc016dd841296970525f88bf6b8a0d67c0167 Mon Sep 17 00:00:00 2001 From: meztihn Date: Sat, 9 Jul 2022 18:14:21 +0500 Subject: [PATCH 1/5] DND: Fix window class matching for names with spaces --- safeeyes/plugins/donotdisturb/plugin.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/safeeyes/plugins/donotdisturb/plugin.py b/safeeyes/plugins/donotdisturb/plugin.py index 207f6ba..5d17990 100644 --- a/safeeyes/plugins/donotdisturb/plugin.py +++ b/safeeyes/plugins/donotdisturb/plugin.py @@ -80,16 +80,15 @@ def is_active_window_skipped_xorg(pre_break): # Extract the process name process_names = re.findall('"(.+?)"', stdout) if process_names: - process = process_names[1].lower() - if process in skip_break_window_classes: + process_name = process_names[1].lower() + if _window_class_matches(process_name, skip_break_window_classes): return True - elif process in take_break_window_classes: + elif _window_class_matches(process_name, take_break_window_classes): if is_fullscreen and unfullscreen_allowed and not pre_break: try: active_window.unfullscreen() - except BaseException: - logging.error( - 'Error in unfullscreen the window ' + process) + except BaseException as e: + logging.error('Error in unfullscreen the window ' + process_name, exc_info=e) return False return is_fullscreen @@ -97,6 +96,10 @@ def is_active_window_skipped_xorg(pre_break): return False +def _window_class_matches(window_class: str, classes: list) -> bool: + return any(map(lambda w: w in classes, window_class.split())) + + def is_on_battery(): """ Check if the computer is running on battery. @@ -131,12 +134,16 @@ def init(ctx, safeeyes_config, plugin_config): global dnd_while_on_battery logging.debug('Initialize Skip Fullscreen plugin') context = ctx - skip_break_window_classes = plugin_config['skip_break_windows'].split() - take_break_window_classes = plugin_config['take_break_windows'].split() + skip_break_window_classes = _normalize_window_classes(plugin_config['skip_break_windows']) + take_break_window_classes = _normalize_window_classes(plugin_config['take_break_windows']) unfullscreen_allowed = plugin_config['unfullscreen'] dnd_while_on_battery = plugin_config['while_on_battery'] +def _normalize_window_classes(classes_as_str: str): + return [w.lower() for w in classes_as_str.split()] + + def on_pre_break(break_obj): """ Lifecycle method executes before the pre-break period. From d6a3596faaec275bec85626a705d07f2b12d3783 Mon Sep 17 00:00:00 2001 From: Gobinath Loganathan Date: Thu, 5 Jan 2023 19:08:29 -0500 Subject: [PATCH 2/5] Add CICD to automatic release --- .github/workflows/release.yml | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6de2476 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Release +on: + push: + branches: [ release ] + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + + - name: Get Current Version + run: | + project_version=$(python3 setup.py --version) + echo "project_version=$project_version" >> $GITHUB_OUTPUT + id: get_current_version + + - name: Create Tag + uses: mathieudutour/github-tag-action@v6.1 + with: + custom_tag: "v${{steps.get_current_version.outputs.project_version}}" + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Changelog + id: build_changelog + uses: mikepenz/release-changelog-builder-action@v3.4.0 + env: + GITHUB_TOKEN: ${{ secrets.GH_API_SECRET }} + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + tag_name: 'v${{steps.get_current_version.outputs.project_version}}' + body: ${{steps.build_changelog.outputs.changelog}} + token: ${{ secrets.GH_API_SECRET }} + + - name: Build Python Package + run: rm -Rf build *.egg-info/ && python3 setup.py sdist bdist_wheel + + - name: Publish to PyPi + uses: pypa/gh-action-pypi-publish@v1.6.4 + with: + password: ${{ secrets.PYPI_API_TOKEN }} From 375bd9d737134f61b8d4938345f291d1f99c18e1 Mon Sep 17 00:00:00 2001 From: Gobinath Loganathan Date: Thu, 5 Jan 2023 19:11:06 -0500 Subject: [PATCH 3/5] Bump the version to 2.1.5 --- debian/changelog | 2 +- safeeyes/glade/about_dialog.glade | 2 +- safeeyes/safeeyes.py | 2 +- setup.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index ddd0f91..1837ba4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -safeeyes (2.1.4-3) lunar; urgency=high +safeeyes (2.1.5-0) lunar; urgency=high * Minor bug fixes * Fix the ecd ..rror if there is no long break diff --git a/safeeyes/glade/about_dialog.glade b/safeeyes/glade/about_dialog.glade index c78679f..16780f7 100644 --- a/safeeyes/glade/about_dialog.glade +++ b/safeeyes/glade/about_dialog.glade @@ -71,7 +71,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.center 10 10 - Safe Eyes 2.1.4 + Safe Eyes 2.1.5 center diff --git a/safeeyes/safeeyes.py b/safeeyes/safeeyes.py index cf24f08..9ce47eb 100644 --- a/safeeyes/safeeyes.py +++ b/safeeyes/safeeyes.py @@ -40,7 +40,7 @@ from safeeyes.ui.settings_dialog import SettingsDialog gi.require_version('Gtk', '3.0') from gi.repository import Gtk -SAFE_EYES_VERSION = "2.1.4" +SAFE_EYES_VERSION = "2.1.5" class SafeEyes: diff --git a/setup.py b/setup.py index 4709aef..d04e820 100644 --- a/setup.py +++ b/setup.py @@ -78,14 +78,14 @@ def __package_data(): setuptools.setup( name="safeeyes", - version="2.1.4", + version="2.1.5", description="Protect your eyes from eye strain using this continuous breaks reminder.", long_description=long_description, long_description_content_type="text/markdown", author="Gobinath Loganathan", author_email="slgobinath@gmail.com", url="https://github.com/slgobinath/SafeEyes", - download_url="https://github.com/slgobinath/SafeEyes/archive/v2.1.4.tar.gz", + download_url="https://github.com/slgobinath/SafeEyes/archive/v2.1.5.tar.gz", packages=setuptools.find_packages(), package_data={'safeeyes': __package_data()}, data_files=__data_files(), From 95da9334e0bb99cf2fa745abc00cbd3018ba8e65 Mon Sep 17 00:00:00 2001 From: Gobinath Loganathan Date: Thu, 5 Jan 2023 19:13:58 -0500 Subject: [PATCH 4/5] Update GH workflow to synchronize after release --- .github/workflows/release.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6de2476..9830a9b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,6 +9,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GH_API_SECRET }} - name: Set up Python 3.10 uses: actions/setup-python@v3 @@ -52,3 +55,13 @@ jobs: uses: pypa/gh-action-pypi-publish@v1.6.4 with: password: ${{ secrets.PYPI_API_TOKEN }} + + - name: Sync Release with Master + run: | + git fetch origin + git checkout release + git pull origin release + git checkout master + git pull origin master + git merge release --ff-only + git push origin master From e79444c699c2720f0f524b05a65e67d8f5562877 Mon Sep 17 00:00:00 2001 From: Gobinath Loganathan Date: Thu, 5 Jan 2023 19:15:26 -0500 Subject: [PATCH 5/5] Fix GH secret --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9830a9b..c475c77 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,7 +33,7 @@ jobs: uses: mathieudutour/github-tag-action@v6.1 with: custom_tag: "v${{steps.get_current_version.outputs.project_version}}" - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.GH_API_SECRET }} - name: Build Changelog id: build_changelog