dbus-notifier 0.2.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dbus_notifier/__init__.py +0 -0
- dbus_notifier/icons/feather_on_grey.png +0 -0
- dbus_notifier/notifysender.py +84 -0
- dbus_notifier-0.2.1.data/data/.env_dbus_notifier +1 -0
- dbus_notifier-0.2.1.data/data/dbus_notifier/icons/feather_on_grey.png +0 -0
- dbus_notifier-0.2.1.dist-info/METADATA +134 -0
- dbus_notifier-0.2.1.dist-info/RECORD +10 -0
- dbus_notifier-0.2.1.dist-info/WHEEL +6 -0
- dbus_notifier-0.2.1.dist-info/licenses/LICENSE +21 -0
- dbus_notifier-0.2.1.dist-info/top_level.txt +1 -0
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides very simple dbus notifications.
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
import dbusnotify
|
|
7
|
+
from dotenv import dotenv_values
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class NotifySender:
|
|
11
|
+
"""
|
|
12
|
+
This class represents a sender of dbus notifications. It can post individual messages, or you can initialise it
|
|
13
|
+
with a dictionary of messages. If the dictionary is present, notifications can be posted by calling the method
|
|
14
|
+
notify with a message selection key.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, title, messages=None):
|
|
18
|
+
self._title = None
|
|
19
|
+
self._messages = None
|
|
20
|
+
self.title = title
|
|
21
|
+
self.messages = messages
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def title(self): # pylint: disable=missing-function-docstring
|
|
25
|
+
return self._title
|
|
26
|
+
|
|
27
|
+
@title.setter
|
|
28
|
+
def title(self, in_str=None):
|
|
29
|
+
self._title = in_str or ""
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def messages(self):
|
|
33
|
+
"""
|
|
34
|
+
A dictionary of pre-prepared messages that can be selected using a key.
|
|
35
|
+
:return: The value of a private member variable
|
|
36
|
+
"""
|
|
37
|
+
return self._messages
|
|
38
|
+
|
|
39
|
+
@messages.setter
|
|
40
|
+
def messages(self, in_dict=None):
|
|
41
|
+
self._messages = in_dict or {}
|
|
42
|
+
|
|
43
|
+
def _post_notification(self, in_title="", in_description=""):
|
|
44
|
+
"""
|
|
45
|
+
This private method posts notifications
|
|
46
|
+
:param in_title: A string containing the notification title
|
|
47
|
+
:param in_description: A string containing the notification message
|
|
48
|
+
:return: void
|
|
49
|
+
"""
|
|
50
|
+
ve_path = os.getenv("VIRTUAL_ENV")
|
|
51
|
+
ve_config = dotenv_values(os.path.join(ve_path, ".env_dbus_notifier"))
|
|
52
|
+
|
|
53
|
+
if ve_config:
|
|
54
|
+
icon_file = os.path.join(ve_path, ve_config.get("DBUS_NOTIFIER_ICON", ''))
|
|
55
|
+
else:
|
|
56
|
+
config = dotenv_values(os.path.join(os.getcwd(), '.env_dbus_notifier'))
|
|
57
|
+
icon_file = os.path.join(os.getcwd(), config.get("DBUS_NOTIFIER_ICON", ''))
|
|
58
|
+
|
|
59
|
+
if not os.path.isfile(icon_file):
|
|
60
|
+
icon_file = ""
|
|
61
|
+
dbusnotify.write(
|
|
62
|
+
in_description,
|
|
63
|
+
title=in_title if in_title else self.title,
|
|
64
|
+
icon=icon_file, # On Windows .ico is required, on Linux - .png
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
def notify(self, message=None, select_key=None):
|
|
68
|
+
"""
|
|
69
|
+
This method posts notifications.
|
|
70
|
+
:param message: A string containing the notification message
|
|
71
|
+
:param select_key: A key value to select a message from a dictionary of messages, if available (this key is
|
|
72
|
+
not needed if `message` is provided)
|
|
73
|
+
:return: void
|
|
74
|
+
"""
|
|
75
|
+
title = self.title
|
|
76
|
+
|
|
77
|
+
if select_key and self.messages:
|
|
78
|
+
self._post_notification(title, self.messages.get(select_key, ""))
|
|
79
|
+
return
|
|
80
|
+
|
|
81
|
+
if not message:
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
self._post_notification(title, message)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DBUS_NOTIFIER_ICON=dbusnotifier/icons/feather_on_grey.png
|
|
Binary file
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dbus-notifier
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A small dbus notifier package
|
|
5
|
+
Author: Adam Bukolt
|
|
6
|
+
Author-email: Adam Bukolt <abukolt@gmx.com>
|
|
7
|
+
Project-URL: Homepage, https://github.com/adambmarsh/dbusnotify
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: annotated-types>=0.6.0
|
|
15
|
+
Requires-Dist: astroid>=3.1.0
|
|
16
|
+
Requires-Dist: attrs>=23.2.0
|
|
17
|
+
Requires-Dist: bleach>=6.1.0
|
|
18
|
+
Requires-Dist: build>=1.1.1
|
|
19
|
+
Requires-Dist: certifi>=2024.2.2
|
|
20
|
+
Requires-Dist: cffi>=1.16.0
|
|
21
|
+
Requires-Dist: charset-normalizer>=3.3.2
|
|
22
|
+
Requires-Dist: check-wheel-contents>=0.6.0
|
|
23
|
+
Requires-Dist: click>=8.1.7
|
|
24
|
+
Requires-Dist: cryptography>=42.0.5
|
|
25
|
+
Requires-Dist: dbus-next>=0.2.3
|
|
26
|
+
Requires-Dist: dbus-python>=1.3.2
|
|
27
|
+
Requires-Dist: dbusnotify>=0.0.2
|
|
28
|
+
Requires-Dist: dill>=0.3.8
|
|
29
|
+
Requires-Dist: docutils>=0.20.1
|
|
30
|
+
Requires-Dist: idna>=3.6
|
|
31
|
+
Requires-Dist: importlib-metadata>=7.1.0
|
|
32
|
+
Requires-Dist: isort>=5.13.2
|
|
33
|
+
Requires-Dist: jaraco-classes>=3.3.1
|
|
34
|
+
Requires-Dist: jaraco-context>=4.3.0
|
|
35
|
+
Requires-Dist: jaraco-functools>=4.0.0
|
|
36
|
+
Requires-Dist: jeepney>=0.8.0
|
|
37
|
+
Requires-Dist: keyring>=25.0.0
|
|
38
|
+
Requires-Dist: markdown-it-py>=3.0.0
|
|
39
|
+
Requires-Dist: mccabe>=0.7.0
|
|
40
|
+
Requires-Dist: mdurl>=0.1.2
|
|
41
|
+
Requires-Dist: more-itertools>=10.2.1
|
|
42
|
+
Requires-Dist: nh3>=0.2.17
|
|
43
|
+
Requires-Dist: packaging>=24.0
|
|
44
|
+
Requires-Dist: pkginfo>=1.10.0
|
|
45
|
+
Requires-Dist: platformdirs>=4.2.0
|
|
46
|
+
Requires-Dist: pycodestyle>=2.11.1
|
|
47
|
+
Requires-Dist: pycparser>=2.21
|
|
48
|
+
Requires-Dist: pydantic>=2.6.4
|
|
49
|
+
Requires-Dist: pydantic-core>=2.17.0
|
|
50
|
+
Requires-Dist: pyflakes>=3.2.0
|
|
51
|
+
Requires-Dist: pygments>=2.17.2
|
|
52
|
+
Requires-Dist: pylint>=3.1.0
|
|
53
|
+
Requires-Dist: pyproject-hooks>=1.0.0
|
|
54
|
+
Requires-Dist: python-dotenv>=1.0.1
|
|
55
|
+
Requires-Dist: readme-renderer>=43.0
|
|
56
|
+
Requires-Dist: requests>=2.31.0
|
|
57
|
+
Requires-Dist: requests-toolbelt>=1.0.0
|
|
58
|
+
Requires-Dist: rfc3986>=2.0.0
|
|
59
|
+
Requires-Dist: rich>=13.7.1
|
|
60
|
+
Requires-Dist: secretstorage>=3.3.3
|
|
61
|
+
Requires-Dist: setuptools>=80.9.0
|
|
62
|
+
Requires-Dist: six>=1.16.0
|
|
63
|
+
Requires-Dist: tomli>=2.0.1
|
|
64
|
+
Requires-Dist: tomlkit>=0.12.4
|
|
65
|
+
Requires-Dist: twine>=5.0.0
|
|
66
|
+
Requires-Dist: typing-extensions>=4.10.0
|
|
67
|
+
Requires-Dist: urllib3>=2.2.1
|
|
68
|
+
Requires-Dist: webencodings>=0.5.1
|
|
69
|
+
Requires-Dist: wheel-filename>=1.4.1
|
|
70
|
+
Requires-Dist: zipp>=3.18.1
|
|
71
|
+
Dynamic: author
|
|
72
|
+
Dynamic: license-file
|
|
73
|
+
Dynamic: requires-python
|
|
74
|
+
|
|
75
|
+
# dbus-notifier #
|
|
76
|
+
|
|
77
|
+
This library offers a simple means of generating dbus notifications on Linux.
|
|
78
|
+
|
|
79
|
+
## Installation and Usage
|
|
80
|
+
|
|
81
|
+
Make sure at least Python 3.* is installed on the target Linux system.
|
|
82
|
+
|
|
83
|
+
Install virtualenv in which to install `dbus-notifier`.
|
|
84
|
+
|
|
85
|
+
In the virtual environment, run `pip3 install dbus-notifier`
|
|
86
|
+
|
|
87
|
+
In the Python code to use dbus-notifier:
|
|
88
|
+
|
|
89
|
+
```commandline
|
|
90
|
+
from dbusnotifier.dbusnotifier import NotifySender
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
The simplest code instantiating NotifySender and sending a dbus notification is this:
|
|
94
|
+
|
|
95
|
+
```commandline
|
|
96
|
+
sender = NotifySender(title="My notifier")
|
|
97
|
+
...
|
|
98
|
+
sender.notify(message="Hi!")
|
|
99
|
+
```
|
|
100
|
+
The above code results in a single message "Hi!" being posting in the notification area.
|
|
101
|
+
|
|
102
|
+
A more complex scenario supported by dbus-notifier is to create a dictionary with a selection of messages, where each
|
|
103
|
+
key identifies a message. The code below illustrates this case:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
sender = NotifySender(title="My notifier", messages={'0': "Success", '1': "Failed"})
|
|
107
|
+
|
|
108
|
+
sender.notify(select_key='0')
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
## Dependencies
|
|
113
|
+
|
|
114
|
+
Please see `pyproject.toml`.
|
|
115
|
+
|
|
116
|
+
## Status
|
|
117
|
+
|
|
118
|
+
Mar 2023 First draft, tested locally on Manjaro Linux.
|
|
119
|
+
Apr 2025 release.
|
|
120
|
+
|
|
121
|
+
## Copyright
|
|
122
|
+
|
|
123
|
+
Copyright Adam Bukolt
|
|
124
|
+
|
|
125
|
+
Note that the copyright refers to the code and scripts in this repository and
|
|
126
|
+
expressly not to any third-party dependencies.
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT
|
|
131
|
+
|
|
132
|
+
Icons included with this program were created by and are the sole property of the copyright holder.
|
|
133
|
+
|
|
134
|
+
Note that separate licenses apply to third-party dependencies.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
dbus_notifier/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
dbus_notifier/notifysender.py,sha256=oRwb4nEpPOWAro2-2gDquItHXnul2O7iXCnICNgjloQ,2741
|
|
3
|
+
dbus_notifier/icons/feather_on_grey.png,sha256=d3AL4ZgDeGeGVA8w_rsDMq44OqXLm38HM4wbmsbBBfQ,9566
|
|
4
|
+
dbus_notifier-0.2.1.data/data/.env_dbus_notifier,sha256=98LpNZCFwtMk1soGOfOEF02pVH5PnF85XZ7fewoAIBg,58
|
|
5
|
+
dbus_notifier-0.2.1.data/data/dbus_notifier/icons/feather_on_grey.png,sha256=d3AL4ZgDeGeGVA8w_rsDMq44OqXLm38HM4wbmsbBBfQ,9566
|
|
6
|
+
dbus_notifier-0.2.1.dist-info/licenses/LICENSE,sha256=L1cs52IMCKn4dLji4fxcFqLkRkRdahfy-Lvl1lhlrxo,1068
|
|
7
|
+
dbus_notifier-0.2.1.dist-info/METADATA,sha256=TexyVXqlcRwZ6dxq4CNcpHUL4PxBkgLjM0BNgqlGGfw,3900
|
|
8
|
+
dbus_notifier-0.2.1.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
|
|
9
|
+
dbus_notifier-0.2.1.dist-info/top_level.txt,sha256=GLRbV7kVsCZ-MygBlXupUb5lHhkLSPSjPSpuMlI9EmM,14
|
|
10
|
+
dbus_notifier-0.2.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Adam Bukolt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dbus_notifier
|