-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWinFetch.py
More file actions
129 lines (109 loc) · 3.91 KB
/
Copy pathWinFetch.py
File metadata and controls
129 lines (109 loc) · 3.91 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import platform
import socket
import colorama
import wmi
import argparse
import time
import getpass
import psutil
import ctypes
import random
colorama.init(autoreset=True)
from colorama import Fore, Style
import os
parser = argparse.ArgumentParser(description="Winfetch CLI tool")
parser.add_argument("--nocolor", "--nocolour", action="store_true", dest="nocolor", help="Disable all colours")
args = parser.parse_args()
def color(text, color_code):
if args.nocolor:
return text
return color_code + text + Style.RESET_ALL
print()
ascii_art = (
color(" ▄▄▄▄ ", Fore.BLUE) + color(" ▄▄▄▄\n", Fore.CYAN) +
color("▄▀ ▀▄", Fore.BLUE) + color("▄▀ ▀▄\n", Fore.CYAN) +
color("▄▀▄▄▄▀", Fore.YELLOW) + color("▄▀▄▄▄▀", Fore.GREEN)
)
print(ascii_art)
print()
message = ["HE HAS RAM GET HIM",
"Nice specs dewd!",
"Winfetch; Windows for Neofetch.. No wait it's the other way around!",
"aujdhdlrjrklr",
"Holy moly look at those specs!",
"mmm... memory chips...",
"I use Windows btw"]
msg =random.choice(message)
print(color(msg, Fore.YELLOW))
print()
def names():
os_name = platform.system()
os_release = platform.release()
os_version = platform.version()
hostname = socket.gethostname()
username = getpass.getuser()
print(color(f"OS: {os_name} {os_release} {os_version}", Fore.BLUE))
print(color(f"Hostname: {hostname}", Fore.BLUE))
print(color(f"USERNAME: {username}:", Fore.BLUE))
print()
def ram_cpu_gpu():
cpu = platform.processor()
ram_bytes = psutil.virtual_memory().total
ram_gb = round(ram_bytes / (1024*1024*1024), 1)
gpu = wmi.WMI()
c = gpu.Win32_VideoController()
all_partitions = psutil.disk_partitions()
for partition in all_partitions:
if "C:" in partition.device or "c:" in partition.device:
mountpoint = partition.device
else:
print(color(f"Disk: Unknown", Fore.LIGHTYELLOW_EX))
break
disk_usage = psutil.disk_usage(partition.mountpoint)
total_gb = disk_usage.total / (1024**3)
total_gb = round(total_gb, 1)
used_gb = disk_usage.used / (1024**3)
used_gb = round(used_gb, 1)
percent = disk_usage.percent
boot_time = psutil.boot_time()
current_time = time.time()
uptime_seconds = int(current_time - boot_time)
uptime_days = uptime_seconds // 86400
uptime_hours = (uptime_seconds % 86400) // 3600
uptime_minutes = (uptime_seconds % 3600) // 60
uptime_seconds = uptime_seconds % 60
gpu_name = c[0].Name if c else "Unknown"
cpu_usage = round(psutil.cpu_percent(), 1)
print(color(f"RAM: {ram_gb} GB", Fore.LIGHTYELLOW_EX))
print(color(f"CPU: {cpu}", Fore.LIGHTYELLOW_EX))
print(color(f"CPU Usage: {cpu_usage}%", Fore.LIGHTYELLOW_EX))
print()
print(color(f"GPU: {gpu_name}", Fore.LIGHTYELLOW_EX))
print(color(f"Disk: {mountpoint} (total: {total_gb}) (used: {used_gb}) (percent: {percent})", Fore.LIGHTYELLOW_EX))
print()
print(color(f"Uptime: {uptime_days}d, {uptime_hours}h, {uptime_minutes}m, {uptime_seconds}s", Fore.LIGHTRED_EX))
def battery():
battery = psutil.sensors_battery()
percent = battery.percent
if battery.power_plugged:
print(color(f"Battery: {percent}% (Charging)", Fore.BLUE))
print()
else:
print(color(f"Battery: {percent}% (Not charging)", Fore.BLUE))
print()
def resolution():
user32 = ctypes.windll.user32
width = user32.GetSystemMetrics(0)
height = user32.GetSystemMetrics(1)
print()
print(color(f"Resolution: {width}x{height}", Fore.YELLOW))
print()
def shell():
shell_path = os.environ.get("COMSPEC", "cmd.exe")
shell_name = os.path.basename(shell_path)
print(color(f"Shell: {shell_name}", Fore.LIGHTMAGENTA_EX))
names()
battery()
ram_cpu_gpu()
resolution()
shell()