Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
iperov
GitHub Repository: iperov/deepfacelab
Path: blob/master/core/osex.py
628 views
1
import os
2
import sys
3
4
if sys.platform[0:3] == 'win':
5
from ctypes import windll
6
from ctypes import wintypes
7
8
def set_process_lowest_prio():
9
try:
10
if sys.platform[0:3] == 'win':
11
GetCurrentProcess = windll.kernel32.GetCurrentProcess
12
GetCurrentProcess.restype = wintypes.HANDLE
13
SetPriorityClass = windll.kernel32.SetPriorityClass
14
SetPriorityClass.argtypes = (wintypes.HANDLE, wintypes.DWORD)
15
SetPriorityClass ( GetCurrentProcess(), 0x00000040 )
16
elif 'darwin' in sys.platform:
17
os.nice(10)
18
elif 'linux' in sys.platform:
19
os.nice(20)
20
except:
21
print("Unable to set lowest process priority")
22
23
def set_process_dpi_aware():
24
if sys.platform[0:3] == 'win':
25
windll.user32.SetProcessDPIAware(True)
26
27
def get_screen_size():
28
if sys.platform[0:3] == 'win':
29
user32 = windll.user32
30
return user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
31
elif 'darwin' in sys.platform:
32
pass
33
elif 'linux' in sys.platform:
34
pass
35
36
return (1366, 768)
37
38