-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
70 lines (60 loc) · 1.98 KB
/
Copy pathutil.py
File metadata and controls
70 lines (60 loc) · 1.98 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
import re
import subprocess
# Gracefully taken from liquidctl
def normalize_profile(profile, critx, max_value=100):
profile = sorted(list(profile) + [(critx, max_value)], key=lambda p: (p[0], -p[1]))
mono = profile[0:1]
for (x, y), (xb, yb) in zip(profile[1:], profile[:-1]):
if x == xb:
continue
if y < yb:
y = yb
mono.append((x, y))
if y == max_value:
break
return mono
def interpolate_profile(profile, x):
lower, upper = profile[0], profile[-1]
for step in profile:
if step[0] <= x:
lower = step
if step[0] >= x:
upper = step
break
if lower[0] == upper[0]:
return lower[1]
return round(lower[1] + (x - lower[0])/(upper[0] - lower[0])*(upper[1] - lower[1]))
def clamp(value, clampmin, clampmax):
clamped = max(clampmin, min(clampmax, value))
return clamped
# ---
def cpu_vendor_and_model_name():
vendor_id = ""
model_name = ""
with open("/proc/cpuinfo", "r") as f:
lines = f.readlines()
for line in lines:
if "vendor_id" in line:
vendor_id = re.sub(".*vendor_id.*: ", "", line).replace("\n","")
if "model name" in line:
model_name = re.sub(".*model name.*: ", "", line).replace("\n","")
break
return (vendor_id, model_name)
def get_video_adapters():
return subprocess.check_output("lspci -k | grep -EA3 'VGA|3D|Display'", shell=True, text=True)
def get_intel_integrated_graphics_name():
if intel_integrated_graphics_present():
adapters = get_video_adapters()
place = adapters.find("[")
intel = adapters[place + 1:]
intel = intel.split("]")[0]
return intel
return None
def intel_integrated_graphics_present():
if "Intel" in get_video_adapters():
return True
return False
def is_nvidia_present():
if "NVIDIA" in get_video_adapters():
return True
return False