-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtigerfetch
More file actions
executable file
·70 lines (55 loc) · 1.91 KB
/
tigerfetch
File metadata and controls
executable file
·70 lines (55 loc) · 1.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
#!/usr/bin/env python3
import psutil
import platform
import subprocess
import getpass
import os
def get_cpu_info():
freq_mhz = psutil.cpu_freq().max
logical_cores = psutil.cpu_count(logical=True)
if freq_mhz:
freq_ghz = freq_mhz / 1000
return f"{freq_ghz:.2f} GHz ({logical_cores} cores)"
return f"N/A ({logical_cores} cores)"
def get_memory():
mem = psutil.virtual_memory()
total = mem.total // (1024 ** 2)
used = mem.used // (1024 ** 2)
return f"{used}MiB / {total}MiB"
def get_gpu_info():
try:
lspci_output = subprocess.check_output(["lspci"], text=True)
gpu_line = next((line for line in lspci_output.splitlines() if "VGA" in line), None)
if not gpu_line:
return "GPU não encontrada"
gpu_name = gpu_line.split(":", 2)[-1].strip()
card_id = gpu_line.split()[0]
return gpu_name
except subprocess.CalledProcessError as e:
return "Erro ao executar comandos", str(e)
def get_distro_name():
if os.path.exists("/etc/os-release"):
with open("/etc/os-release") as f:
for line in f:
if line.startswith("NAME="):
return line.strip().split("=")[1].strip('"')
return "tigerfech"
def get_de():
return os.environ.get("DESKTOP_SESSION").capitalize()
def tigerfetch():
cpu = get_cpu_info()
gpu = get_gpu_info()
memory = get_memory()
kernel = platform.release()
user = getpass.getuser()
distro = get_distro_name()
de = get_de()
subprocess.run(f'figlet "{distro}"', shell=True)
print(f"\033[31m USER \033[0m{user}")
print(f"\033[31m CPU \033[0m{cpu}")
print(f"\033[31m GPU: \033[0m{gpu}")
print(f"\033[31m MEM \033[0m{memory}")
print(f"\033[31m KERNEL \033[0m{kernel}")
print(f"\033[31m DE: \033[0m{de}")
if __name__ == "__main__":
tigerfetch()