sot 1.0.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.
- sot-1.0.0/LICENSE +22 -0
- sot-1.0.0/PKG-INFO +120 -0
- sot-1.0.0/README.md +70 -0
- sot-1.0.0/pyproject.toml +45 -0
- sot-1.0.0/setup.cfg +4 -0
- sot-1.0.0/src/sot/__about__.py +4 -0
- sot-1.0.0/src/sot/__init__.py +6 -0
- sot-1.0.0/src/sot/_app.py +107 -0
- sot-1.0.0/src/sot/_battery.py +62 -0
- sot-1.0.0/src/sot/_cpu.py +346 -0
- sot-1.0.0/src/sot/_disk.py +187 -0
- sot-1.0.0/src/sot/_helpers.py +14 -0
- sot-1.0.0/src/sot/_info.py +84 -0
- sot-1.0.0/src/sot/_mem.py +106 -0
- sot-1.0.0/src/sot/_net.py +223 -0
- sot-1.0.0/src/sot/_procs_list.py +139 -0
- sot-1.0.0/src/sot/_sot.py +37 -0
- sot-1.0.0/src/sot/blockchar_stream.py +28 -0
- sot-1.0.0/src/sot/braille_stream.py +149 -0
- sot-1.0.0/src/sot.egg-info/PKG-INFO +120 -0
- sot-1.0.0/src/sot.egg-info/SOURCES.txt +24 -0
- sot-1.0.0/src/sot.egg-info/dependency_links.txt +1 -0
- sot-1.0.0/src/sot.egg-info/entry_points.txt +2 -0
- sot-1.0.0/src/sot.egg-info/requires.txt +5 -0
- sot-1.0.0/src/sot.egg-info/top_level.txt +1 -0
- sot-1.0.0/tests/test_streams.py +90 -0
sot-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Kumar Anirudha
|
|
4
|
+
Copyright (c) 2021-2022 Nico Schlömer
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
sot-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sot
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: System Oberving Tool
|
|
5
|
+
Author-email: Kumar Anirudha <dev@anirudha.dev>
|
|
6
|
+
License: The MIT License (MIT)
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024, Kumar Anirudha
|
|
9
|
+
Copyright (c) 2021-2022 Nico Schlömer
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Code, https://github.com/anistark/sot
|
|
30
|
+
Project-URL: Issues, https://github.com/anistark/sot/issues
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
34
|
+
Classifier: Operating System :: MacOS
|
|
35
|
+
Classifier: Programming Language :: Python
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
41
|
+
Classifier: Topic :: Utilities
|
|
42
|
+
Requires-Python: >=3.7
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE
|
|
45
|
+
Requires-Dist: py-cpuinfo
|
|
46
|
+
Requires-Dist: distro
|
|
47
|
+
Requires-Dist: psutil
|
|
48
|
+
Requires-Dist: rich>=11.0.0
|
|
49
|
+
Requires-Dist: textual<0.2,>=0.1.15
|
|
50
|
+
|
|
51
|
+
<p align="center">
|
|
52
|
+
<a href="https://github.com/anistark/sot"><img alt="tiptop" src="./images/sot.png" width="200px"/></a>
|
|
53
|
+
<p align="center">Command-line system oberving tool.</p>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
`sot` is a Command-line System Obervation Tool in the spirit of [top](<https://en.wikipedia.org/wiki/Top_(software)>). It displays various interesting system stats and graphs them. Works on all operating systems.
|
|
57
|
+
|
|
58
|
+
Install and run with
|
|
59
|
+
|
|
60
|
+
<!--pytest-codeblocks: skip-->
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
pip install sot
|
|
64
|
+
sot
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
For all options, see
|
|
68
|
+
|
|
69
|
+
<!--pytest-codeblocks:skipif(sys.version_info < (3, 10))-->
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
sot -H
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
<!--pytest-codeblocks: expected-output-->
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
usage: sot [--help] [--version] [--log LOG] [--net NET]
|
|
79
|
+
|
|
80
|
+
Command-line System Obervation Tool ≈
|
|
81
|
+
|
|
82
|
+
options:
|
|
83
|
+
--help, -H Show this help message and exit.
|
|
84
|
+
--version, -V Display version information
|
|
85
|
+
--log, -L LOG Debug log file
|
|
86
|
+
--net, -N NET Network interface to display (default: auto)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Main Theme:
|
|
90
|
+
|
|
91
|
+
| Color | Hex | RGB |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| sky_blue3 | `#5fafd7` | `rgb(95,175,215)` |
|
|
94
|
+
| aquamarine3 | `#5fd7af` | `rgb(95,215,175)` |
|
|
95
|
+
| yellow | `#808000` | `rgb(128,128,0)` |
|
|
96
|
+
| bright_black | `#808080` | `rgb(128,128,128)` |
|
|
97
|
+
| slate_blue1 | `#875fff` | `rgb(135,95,255)` |
|
|
98
|
+
| red3 | `#d70000` | `rgb(215,0,0)` |
|
|
99
|
+
| dark_orange | `#d75f00` | `rgb(215,95,0)` |
|
|
100
|
+
|
|
101
|
+
All supported [colors](https://rich.readthedocs.io/en/latest/appendix/colors.html).
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
<p align="center">
|
|
106
|
+
<p align="center">🏴 ≈ 🏴</p>
|
|
107
|
+
</p>
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
`sot` uses [Textual](https://github.com/willmcgugan/textual/) for layouting, [rich](https://rich.readthedocs.io/en/latest/index.html) for rich text and [psutil](https://github.com/giampaolo/psutil) for fetching system data.
|
|
112
|
+
|
|
113
|
+
Other top alternatives in alphabetical order:
|
|
114
|
+
|
|
115
|
+
- [tiptop](https://github.com/nschloe/tiptop) ✨ This project was created on top of `tiptop`, when it became unmaintained.
|
|
116
|
+
- [bashtop](https://github.com/aristocratos/bashtop), [bpytop](https://github.com/aristocratos/bpytop), [btop](https://github.com/aristocratos/btop)
|
|
117
|
+
- [bottom](https://github.com/ClementTsang/bottom) (one of my fav)
|
|
118
|
+
- [Glances](https://github.com/nicolargo/glances)
|
|
119
|
+
- [gtop](https://github.com/aksakalli/gtop)
|
|
120
|
+
- [htop](https://github.com/htop-dev/htop)
|
sot-1.0.0/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/anistark/sot"><img alt="tiptop" src="./images/sot.png" width="200px"/></a>
|
|
3
|
+
<p align="center">Command-line system oberving tool.</p>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
`sot` is a Command-line System Obervation Tool in the spirit of [top](<https://en.wikipedia.org/wiki/Top_(software)>). It displays various interesting system stats and graphs them. Works on all operating systems.
|
|
7
|
+
|
|
8
|
+
Install and run with
|
|
9
|
+
|
|
10
|
+
<!--pytest-codeblocks: skip-->
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
pip install sot
|
|
14
|
+
sot
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For all options, see
|
|
18
|
+
|
|
19
|
+
<!--pytest-codeblocks:skipif(sys.version_info < (3, 10))-->
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
sot -H
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
<!--pytest-codeblocks: expected-output-->
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
usage: sot [--help] [--version] [--log LOG] [--net NET]
|
|
29
|
+
|
|
30
|
+
Command-line System Obervation Tool ≈
|
|
31
|
+
|
|
32
|
+
options:
|
|
33
|
+
--help, -H Show this help message and exit.
|
|
34
|
+
--version, -V Display version information
|
|
35
|
+
--log, -L LOG Debug log file
|
|
36
|
+
--net, -N NET Network interface to display (default: auto)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Main Theme:
|
|
40
|
+
|
|
41
|
+
| Color | Hex | RGB |
|
|
42
|
+
| --- | --- | --- |
|
|
43
|
+
| sky_blue3 | `#5fafd7` | `rgb(95,175,215)` |
|
|
44
|
+
| aquamarine3 | `#5fd7af` | `rgb(95,215,175)` |
|
|
45
|
+
| yellow | `#808000` | `rgb(128,128,0)` |
|
|
46
|
+
| bright_black | `#808080` | `rgb(128,128,128)` |
|
|
47
|
+
| slate_blue1 | `#875fff` | `rgb(135,95,255)` |
|
|
48
|
+
| red3 | `#d70000` | `rgb(215,0,0)` |
|
|
49
|
+
| dark_orange | `#d75f00` | `rgb(215,95,0)` |
|
|
50
|
+
|
|
51
|
+
All supported [colors](https://rich.readthedocs.io/en/latest/appendix/colors.html).
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
<p align="center">
|
|
56
|
+
<p align="center">🏴 ≈ 🏴</p>
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
`sot` uses [Textual](https://github.com/willmcgugan/textual/) for layouting, [rich](https://rich.readthedocs.io/en/latest/index.html) for rich text and [psutil](https://github.com/giampaolo/psutil) for fetching system data.
|
|
62
|
+
|
|
63
|
+
Other top alternatives in alphabetical order:
|
|
64
|
+
|
|
65
|
+
- [tiptop](https://github.com/nschloe/tiptop) ✨ This project was created on top of `tiptop`, when it became unmaintained.
|
|
66
|
+
- [bashtop](https://github.com/aristocratos/bashtop), [bpytop](https://github.com/aristocratos/bpytop), [btop](https://github.com/aristocratos/btop)
|
|
67
|
+
- [bottom](https://github.com/ClementTsang/bottom) (one of my fav)
|
|
68
|
+
- [Glances](https://github.com/nicolargo/glances)
|
|
69
|
+
- [gtop](https://github.com/aksakalli/gtop)
|
|
70
|
+
- [htop](https://github.com/htop-dev/htop)
|
sot-1.0.0/pyproject.toml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[tool.isort]
|
|
6
|
+
profile = "black"
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "sot"
|
|
10
|
+
authors = [{name = "Kumar Anirudha", email = "dev@anirudha.dev"}]
|
|
11
|
+
description = "System Oberving Tool"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
license = {file = "LICENSE"}
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: POSIX :: Linux",
|
|
18
|
+
"Operating System :: MacOS",
|
|
19
|
+
"Programming Language :: Python",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.7",
|
|
22
|
+
"Programming Language :: Python :: 3.8",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Topic :: Utilities",
|
|
26
|
+
]
|
|
27
|
+
dynamic = ["version"]
|
|
28
|
+
requires-python = ">=3.7"
|
|
29
|
+
dependencies = [
|
|
30
|
+
"py-cpuinfo",
|
|
31
|
+
"distro",
|
|
32
|
+
"psutil",
|
|
33
|
+
"rich >= 11.0.0",
|
|
34
|
+
"textual >=0.1.15, <0.2",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.dynamic]
|
|
38
|
+
version = {attr = "sot.__about__.__version__"}
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Code = "https://github.com/anistark/sot"
|
|
42
|
+
Issues = "https://github.com/anistark/sot/issues"
|
|
43
|
+
|
|
44
|
+
[project.scripts]
|
|
45
|
+
sot = "sot._app:run"
|
sot-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
from sys import version_info
|
|
5
|
+
|
|
6
|
+
from textual.app import App
|
|
7
|
+
|
|
8
|
+
from .__about__ import __version__, __current_year__
|
|
9
|
+
from ._cpu import CPU
|
|
10
|
+
from ._disk import Disk
|
|
11
|
+
from ._info import InfoLine
|
|
12
|
+
from ._mem import Mem
|
|
13
|
+
from ._net import Net
|
|
14
|
+
from ._procs_list import ProcsList
|
|
15
|
+
# from ._sot import Sot
|
|
16
|
+
|
|
17
|
+
def run(argv=None):
|
|
18
|
+
parser = argparse.ArgumentParser(
|
|
19
|
+
description="Command-line System Obervation Tool ≈",
|
|
20
|
+
formatter_class=argparse.RawTextHelpFormatter,
|
|
21
|
+
add_help=False
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
parser.add_argument(
|
|
25
|
+
"--help",
|
|
26
|
+
"-H",
|
|
27
|
+
action="help",
|
|
28
|
+
default=argparse.SUPPRESS,
|
|
29
|
+
help="Show this help message and exit."
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
"--version",
|
|
34
|
+
"-V",
|
|
35
|
+
action="version",
|
|
36
|
+
version=_get_version_text(),
|
|
37
|
+
help="Display version information",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
parser.add_argument(
|
|
41
|
+
"--log",
|
|
42
|
+
"-L",
|
|
43
|
+
type=str,
|
|
44
|
+
default=None,
|
|
45
|
+
help="Debug log file",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
parser.add_argument(
|
|
49
|
+
"--net",
|
|
50
|
+
"-N",
|
|
51
|
+
type=str,
|
|
52
|
+
default=None,
|
|
53
|
+
help="Network interface to display (default: auto)",
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
args = parser.parse_args(argv)
|
|
57
|
+
|
|
58
|
+
# with a grid
|
|
59
|
+
class sotApp(App):
|
|
60
|
+
async def on_mount(self) -> None:
|
|
61
|
+
grid = await self.view.dock_grid(edge="left")
|
|
62
|
+
|
|
63
|
+
grid.add_column(fraction=36, name="left")
|
|
64
|
+
# grid.add_column(fraction=15, name="middle")
|
|
65
|
+
# grid.add_column(fraction=36, name="right")
|
|
66
|
+
grid.add_column(fraction=45, name="right")
|
|
67
|
+
|
|
68
|
+
grid.add_row(size=1, name="r0")
|
|
69
|
+
grid.add_row(fraction=1, name="r1")
|
|
70
|
+
grid.add_row(fraction=1, name="r2")
|
|
71
|
+
grid.add_row(fraction=1, name="r3")
|
|
72
|
+
grid.add_areas(
|
|
73
|
+
area0="left-start|right-end,r0",
|
|
74
|
+
area1="left,r1",
|
|
75
|
+
# area2a="middle,r1-start|r1-end",
|
|
76
|
+
# area2b="middle,r2-start|r2-end",
|
|
77
|
+
# area2c="middle,r3-start|r3-end",
|
|
78
|
+
area3a="right,r1",
|
|
79
|
+
area3b="right,r2",
|
|
80
|
+
area3c="right,r3",
|
|
81
|
+
area4="left,r2-start|r3-end",
|
|
82
|
+
)
|
|
83
|
+
grid.place(
|
|
84
|
+
area0=InfoLine(),
|
|
85
|
+
area1=CPU(),
|
|
86
|
+
# area2b=Sot(),
|
|
87
|
+
area3a=Mem(),
|
|
88
|
+
area3b=Disk(),
|
|
89
|
+
area3c=Net(args.net),
|
|
90
|
+
area4=ProcsList(),
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
async def on_load(self, _):
|
|
94
|
+
await self.bind("q", "quit", "quit")
|
|
95
|
+
|
|
96
|
+
sotApp.run(log=args.log)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _get_version_text():
|
|
100
|
+
python_version = f"{version_info.major}.{version_info.minor}.{version_info.micro}"
|
|
101
|
+
|
|
102
|
+
return "\n".join(
|
|
103
|
+
[
|
|
104
|
+
f"sot {__version__} [Python {python_version}]",
|
|
105
|
+
f"Copyright (c) 2024-{__current_year__} Kumar Anirudha",
|
|
106
|
+
]
|
|
107
|
+
)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import psutil
|
|
2
|
+
from rich import box
|
|
3
|
+
from rich.panel import Panel
|
|
4
|
+
from rich.text import Text
|
|
5
|
+
from textual.widget import Widget
|
|
6
|
+
|
|
7
|
+
from .braille_stream import BrailleStream
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Battery(Widget):
|
|
11
|
+
def on_mount(self):
|
|
12
|
+
self.bat_stream = BrailleStream(40, 3, 0.0, 100.0)
|
|
13
|
+
|
|
14
|
+
self.panel = Panel(
|
|
15
|
+
"",
|
|
16
|
+
title="",
|
|
17
|
+
title_align="left",
|
|
18
|
+
# border_style="yellow",
|
|
19
|
+
border_style="bright_black",
|
|
20
|
+
box=box.SQUARE,
|
|
21
|
+
)
|
|
22
|
+
self.collect_data()
|
|
23
|
+
# update frequency: 1 min
|
|
24
|
+
self.set_interval(60.0, self.collect_data)
|
|
25
|
+
|
|
26
|
+
def collect_data(self):
|
|
27
|
+
bat = psutil.sensors_battery()
|
|
28
|
+
assert bat is not None
|
|
29
|
+
|
|
30
|
+
self.bat_stream.add_value(bat.percent)
|
|
31
|
+
self.refresh_graph()
|
|
32
|
+
|
|
33
|
+
if bat.power_plugged:
|
|
34
|
+
status = "charging"
|
|
35
|
+
else:
|
|
36
|
+
mm = bat.secsleft // 60
|
|
37
|
+
hh, mm = divmod(mm, 60)
|
|
38
|
+
time_left_str = []
|
|
39
|
+
if hh > 0:
|
|
40
|
+
time_left_str.append(f"{hh}h")
|
|
41
|
+
if mm > 0:
|
|
42
|
+
time_left_str.append(f"{mm}min")
|
|
43
|
+
status = " ".join(time_left_str) + " left"
|
|
44
|
+
|
|
45
|
+
title = f"[b]battery[/] - {self.bat_stream.values[-1]:.1f}% - {status}"
|
|
46
|
+
if bat.percent < 15 and not bat.power_plugged:
|
|
47
|
+
title = "[red3 reverse bold]" + title + "[/]"
|
|
48
|
+
|
|
49
|
+
self.panel.title = title
|
|
50
|
+
|
|
51
|
+
self.refresh()
|
|
52
|
+
|
|
53
|
+
def refresh_graph(self):
|
|
54
|
+
self.panel.renderable = Text("\n".join(self.bat_stream.graph), style="yellow")
|
|
55
|
+
|
|
56
|
+
def render(self) -> Panel:
|
|
57
|
+
return self.panel
|
|
58
|
+
|
|
59
|
+
async def on_resize(self, event):
|
|
60
|
+
self.bat_stream.reset_width(event.width - 4)
|
|
61
|
+
self.bat_stream.reset_height(event.height - 2)
|
|
62
|
+
self.refresh_graph()
|