Skip to content

Commit

Permalink
Merge branch 'beta' of github.com:oskarsh/Yin-Yang into add-flatpak
Browse files Browse the repository at this point in the history
  • Loading branch information
chase9 committed Apr 19, 2024
2 parents 9209b0c + 9188801 commit 297e1ff
Show file tree
Hide file tree
Showing 12 changed files with 323 additions and 120 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ jobs:
run: |
sudo apt install qt6-base-dev libsystemd-dev gcc
- name: Install Poetry dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction
poetry install --sync --no-interaction
# Compile and build Yin-Yang
- name: Compile ui, translations and resources
run: poetry run ./scripts/build_ui.sh
Expand All @@ -67,6 +67,11 @@ jobs:
arch: [x86_64]
steps:
- uses: actions/checkout@v4
- name: Install deps
run: |
dnf -y install pipx
pipx ensurepath
pipx install poetry==1.5.1
- name: Download build from last step
uses: actions/download-artifact@v4
with:
Expand All @@ -77,4 +82,4 @@ jobs:
bundle: yin-yang.flatpak
manifest-path: sh.oskar.yin-yang.json
cache-key: flatpak-builder-${{ github.sha }}
arch: ubuntu-22.04
arch: x86_64
9 changes: 6 additions & 3 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,35 @@ jobs:
os: [ubuntu-22.04]
runs-on: ${{matrix.os}}
steps:
# Checkout repo and set up python
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
# Install and configure poetry
- name: Install Poetry
uses: abatilo/actions-poetry@v2
- name: Set up local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
# Load cached venv if it exists
- name: Cache packages
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
# This path is specific to ubuntu
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
# Install dependencies
# Install dependencies of cache does not exist
- name: Install system dependencies
run: |
sudo apt install qt6-base-dev libsystemd-dev gcc
- name: Install Poetry dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction
poetry install --sync --no-interaction
# Build and test Yin-Yang
- name: Compile ui, translations and resources
run: poetry run ./scripts/build_ui.sh
Expand Down
17 changes: 16 additions & 1 deletion generated-poetry-sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "poetry-deps",
"buildsystem": "simple",
"build-commands": [
"pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} certifi charset-normalizer colorama flake8 idna iniconfig mccabe packaging pluggy psutil pycodestyle pyflakes pyside6-addons pyside6-essentials pytest python-dateutil pyyaml requests shiboken6 six suntime systemd-python toml urllib3"
"pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} certifi charset-normalizer colorama cython flake8 idna iniconfig mccabe packaging pluggy psutil pycodestyle pyflakes pyside6-addons pyside6-essentials pytest python-dateutil pyyaml requests setuptools shiboken6 six suntime systemd-python toml urllib3 wheel"
],
"sources": [
{
Expand All @@ -20,6 +20,11 @@
"url": "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl",
"sha256": "4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/7e/26/9d8de10005fedb1eceabe713348d43bae1dbab1786042ca0751a2e2b0f8c/Cython-0.29.37-py2.py3-none-any.whl",
"sha256": "95f1d6a83ef2729e67b3fa7318c829ce5b07ac64c084cd6af11c228e0364662c"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/e3/01/cc8cdec7b61db0315c2ab62d80677a138ef06832ec17f04d87e6ef858f7f/flake8-7.0.0-py2.py3-none-any.whl",
Expand Down Expand Up @@ -95,6 +100,11 @@
"url": "https://files.pythonhosted.org/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl",
"sha256": "58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/f7/29/13965af254e3373bceae8fb9a0e6ea0d0e571171b80d6646932131d6439b/setuptools-69.5.1-py3-none-any.whl",
"sha256": "c636ac361bc47580504644275c9ad802c50415c7522212252c033bd15f301f32"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/77/f1/feb2a8be699f91fb27fbe8758b405fb38a22e3ae5bd5e05258dbef18d462/shiboken6-6.6.3.1-cp38-abi3-manylinux_2_28_x86_64.whl",
Expand Down Expand Up @@ -124,6 +134,11 @@
"type": "file",
"url": "https://files.pythonhosted.org/packages/a2/73/a68704750a7679d0b6d3ad7aa8d4da8e14e151ae82e6fee774e6e0d05ec8/urllib3-2.2.1-py3-none-any.whl",
"sha256": "450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/7d/cd/d7460c9a869b16c3dd4e1e403cce337df165368c71d6af229a74699622ce/wheel-0.43.0-py3-none-any.whl",
"sha256": "55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81"
}
]
}
83 changes: 82 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ flake8 = "^7.0.0"
pytest = "^8.1.1"
pyyaml = "^6.0.1"
toml = "^0.10.2"
setuptools = "^69.5.1"
wheel = "^0.43.0"
cython = "<3.0"

[build-system]
requires = ["poetry-core"]
Expand Down
2 changes: 1 addition & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ echo "Installing dependencies …"
# Tell Poetry not to use a keyring
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
# create virtual environment and install packages
poetry install --sync
poetry env use python
poetry install --sync
poetry build
pip install ./dist/yin_yang-*-py3-none-any.whl

Expand Down
1 change: 0 additions & 1 deletion sh.oskar.yin-yang.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"buildsystem": "simple",
"build-commands": [
"poetry install --sync",
"poetry build",
"find dist -name 'yin_yang-*-py3-none-any.whl' -exec pip install --no-deps --no-build-isolation --prefix=/app {} \\;",
"install -D runner.sh /app/bin/runner.sh"
],
Expand Down
34 changes: 26 additions & 8 deletions yin_yang/NotificationHandler.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
import logging
import subprocess
from logging import Handler

logger = logging.getLogger()
from PySide6.QtDBus import QDBusConnection, QDBusMessage


def create_dbus_message(title: str, body: str):
message = QDBusMessage.createMethodCall(
"org.freedesktop.portal.Desktop",
"/org/freedesktop/portal/desktop",
"org.freedesktop.portal.Notification",
"AddNotification",
)

notification = {
"title": title,
"body": body,
"icon": "yin_yang",
"priority": "low",
}

message.setArguments(["YingYang.ThemeChanged", notification])

return message


class NotificationHandler(Handler):
"""Shows logs as notifications"""

def emit(self, record):
try:
subprocess.call(['notify-send', record.levelname, str(record.msg),
'-a', 'Yin & Yang', '-u', 'low', '--icon', 'yin_yang'])
except FileNotFoundError:
logger.warn('notify-send not found. Notifications will not work!')
connection = QDBusConnection.sessionBus()
message = create_dbus_message(record.levelname, str(record.msg))
connection.call(message)
19 changes: 18 additions & 1 deletion yin_yang/plugins/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from abc import ABC, abstractmethod
from configparser import ConfigParser
from pathlib import Path
from typing import Optional
from typing import Optional, List

from PySide6.QtDBus import QDBusConnection, QDBusMessage
from PySide6.QtGui import QColor, QRgba64
Expand Down Expand Up @@ -366,3 +366,20 @@ def flatpak_user(app_id: str) -> Path:

def snap_path(app: str) -> Path:
return Path(f'/var/lib/snapd/snap/{app}/current')

def themes_from_theme_directories(type: str) -> List[Path]:
theme_directories = [
Path('/usr/share/themes'),
Path('/usr/local/share/themes'),
Path.home() / '.themes',
Path.home() / '.local/share/themes',
]

themes = []
for directory in theme_directories:
if not directory.is_dir():
continue

themes.extend(d.name for d in directory.iterdir() if d.is_dir() and (d / type).is_dir())

return themes
Loading

0 comments on commit 297e1ff

Please sign in to comment.