forked from oskarsh/Yin-Yang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'beta' of github.com:oskarsh/Yin-Yang into add-flatpak
- Loading branch information
Showing
12 changed files
with
318 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.