-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor2app.py
More file actions
29 lines (21 loc) · 772 Bytes
/
monitor2app.py
File metadata and controls
29 lines (21 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import time
import psutil
import sys
def clear_screen():
os.system('clear') # For macOS and Linux
def main():
while True:
memory_percent = psutil.virtual_memory().percent
cpu_percent = psutil.cpu_percent()
battery_percent = psutil.sensors_battery().percent if hasattr(psutil, 'sensors_battery') else None
clear_screen() # Clear the entire console screen
print(f"Memory Percent: {memory_percent}%")
print(f"CPU Percent: {cpu_percent}%")
if battery_percent:
print(f"Battery Percent: {battery_percent}%")
else:
print("Battery status not available.")
time.sleep(0.5) # Wait for 0.5 seconds before the next update
if __name__ == "__main__":
main()