ootbat2 0.1.0__tar.gz
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.
- ootbat2-0.1.0/OOT_LowHealth.wav +0 -0
- ootbat2-0.1.0/PKG-INFO +23 -0
- ootbat2-0.1.0/README.md +8 -0
- ootbat2-0.1.0/ootbat2.egg-info/PKG-INFO +23 -0
- ootbat2-0.1.0/ootbat2.egg-info/SOURCES.txt +10 -0
- ootbat2-0.1.0/ootbat2.egg-info/dependency_links.txt +1 -0
- ootbat2-0.1.0/ootbat2.egg-info/entry_points.txt +2 -0
- ootbat2-0.1.0/ootbat2.egg-info/requires.txt +1 -0
- ootbat2-0.1.0/ootbat2.egg-info/top_level.txt +1 -0
- ootbat2-0.1.0/ootbat2.py +51 -0
- ootbat2-0.1.0/setup.cfg +4 -0
- ootbat2-0.1.0/setup.py +34 -0
|
Binary file
|
ootbat2-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ootbat2
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: linux low battery alerting tool
|
|
5
|
+
Home-page: https://github.com/vesche/ootbat2
|
|
6
|
+
Author: Austin Jackson
|
|
7
|
+
Author-email: vesche@protonmail.com
|
|
8
|
+
License: UNLICENSE
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: License :: Public Domain
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: playsound
|
|
15
|
+
|
|
16
|
+
# ootbat2
|
|
17
|
+
|
|
18
|
+
linux low battery alerting tool
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
$ pip install ootbat2
|
|
22
|
+
$ ~/.local/bin/ootbat2 &
|
|
23
|
+
```
|
ootbat2-0.1.0/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ootbat2
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: linux low battery alerting tool
|
|
5
|
+
Home-page: https://github.com/vesche/ootbat2
|
|
6
|
+
Author: Austin Jackson
|
|
7
|
+
Author-email: vesche@protonmail.com
|
|
8
|
+
License: UNLICENSE
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: License :: Public Domain
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: playsound
|
|
15
|
+
|
|
16
|
+
# ootbat2
|
|
17
|
+
|
|
18
|
+
linux low battery alerting tool
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
$ pip install ootbat2
|
|
22
|
+
$ ~/.local/bin/ootbat2 &
|
|
23
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
playsound
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ootbat2
|
ootbat2-0.1.0/ootbat2.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
|
|
3
|
+
import os, re, time, subprocess, shutil
|
|
4
|
+
from playsound import playsound
|
|
5
|
+
|
|
6
|
+
path_sysfs_power_supply = '/sys/class/power_supply'
|
|
7
|
+
path_oot_low_health_wav = os.path.join(os.getcwd(), 'OOT_LowHealth.wav')
|
|
8
|
+
low_battery_setting = 99
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_number_of_batteries() -> int:
|
|
12
|
+
return len([f for f in os.listdir(path_sysfs_power_supply) if re.match(r'^BAT\d+$', f)])
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_battery_data(number_of_batteries: int) -> dict:
|
|
16
|
+
battery_data = dict()
|
|
17
|
+
for n in range(number_of_batteries):
|
|
18
|
+
battery_name = f'BAT{n}'
|
|
19
|
+
path_battery = os.path.join(path_sysfs_power_supply, battery_name)
|
|
20
|
+
path_battery_capacity = os.path.join(path_battery, 'capacity')
|
|
21
|
+
path_battery_status = os.path.join(path_battery, 'status')
|
|
22
|
+
with open(path_battery_capacity) as f:
|
|
23
|
+
battery_percentage = int(f.read())
|
|
24
|
+
with open(path_battery_status) as f:
|
|
25
|
+
battery_status = f.read().strip()
|
|
26
|
+
battery_data[battery_name] = {
|
|
27
|
+
'percentage': battery_percentage,
|
|
28
|
+
'status': battery_status
|
|
29
|
+
}
|
|
30
|
+
return battery_data
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def main():
|
|
34
|
+
number_of_batteries = get_number_of_batteries()
|
|
35
|
+
notify_send_exists = shutil.which('notify-send') is not None
|
|
36
|
+
try:
|
|
37
|
+
while True:
|
|
38
|
+
battery_data = get_battery_data(number_of_batteries)
|
|
39
|
+
battery_percentage = sum(battery['percentage'] for battery in battery_data.values())
|
|
40
|
+
battery_statuses = {battery['status'] for battery in battery_data.values()}
|
|
41
|
+
if (battery_percentage < low_battery_setting) and ('Discharging' in battery_statuses):
|
|
42
|
+
if notify_send_exists:
|
|
43
|
+
subprocess.run(['notify-send', 'ootbat2', 'Low battery, charge me!'])
|
|
44
|
+
playsound(path_oot_low_health_wav)
|
|
45
|
+
time.sleep(3)
|
|
46
|
+
except KeyboardInterrupt:
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if __name__ == '__main__':
|
|
51
|
+
main()
|
ootbat2-0.1.0/setup.cfg
ADDED
ootbat2-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from setuptools import setup
|
|
5
|
+
|
|
6
|
+
directory = os.path.abspath(os.path.dirname(__file__))
|
|
7
|
+
with open(os.path.join(directory, 'README.md'), encoding='utf-8') as f:
|
|
8
|
+
long_description = f.read()
|
|
9
|
+
|
|
10
|
+
setup(
|
|
11
|
+
name='ootbat2',
|
|
12
|
+
py_modules=['ootbat2'],
|
|
13
|
+
version='0.1.0',
|
|
14
|
+
description='linux low battery alerting tool',
|
|
15
|
+
long_description=long_description,
|
|
16
|
+
long_description_content_type='text/markdown',
|
|
17
|
+
license='UNLICENSE',
|
|
18
|
+
url='https://github.com/vesche/ootbat2',
|
|
19
|
+
author='Austin Jackson',
|
|
20
|
+
author_email='vesche@protonmail.com',
|
|
21
|
+
install_requires=['playsound'],
|
|
22
|
+
data_files=[('', ['OOT_LowHealth.wav'])],
|
|
23
|
+
entry_points={
|
|
24
|
+
'console_scripts': [
|
|
25
|
+
'ootbat2=ootbat2:main',
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
classifiers=[
|
|
29
|
+
'Development Status :: 5 - Production/Stable',
|
|
30
|
+
'License :: Public Domain',
|
|
31
|
+
'Programming Language :: Python :: 3',
|
|
32
|
+
'Programming Language :: Python :: 3.13',
|
|
33
|
+
],
|
|
34
|
+
)
|