forked from Opticos/GWSL-Source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwsl_tools.py
118 lines (94 loc) · 3.37 KB
/
wsl_tools.py
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
import os
import subprocess
import time
script = None
def pat_con(path):
if "/" in path:
pt = path.split("/")
else:
pt = path.split("\\")
lin = "/mnt/" + pt[0][0].lower()
for f in pt[1:]:
lin += "/" + str(f.lower())
return lin
def get_themes(machine):
cmd = 'wsl.exe -d ' + str(machine) + ' "' + str(pat_con(script)) + '" listthemes'
read = os.popen(cmd).read()
read = read.split(":theme:")
read[:] = (value for value in read if value != "\n")
read[:] = (value for value in read if value != "\n\n")
themes = []
for theme in read:
if theme.startswith("\n"):
theme = theme[1:]
if theme == "/usr/share/themes":
continue
string = "/usr/share/themes/"
if string in theme:
theme = theme[theme.index(string) + len(string):]
string2 = ".themes/"
if string2 in theme:
theme = theme[theme.index(string2) + len(string2):]
themes.append(theme)
return themes
def get_apps(machine):
# try:
# os.remove(script[:-15] + ".scanapps")
# except:
# pass
cmd = 'wsl.exe -d ' + str(machine) + ' "' + str(pat_con(script)) + '" listapps'
read = os.popen(cmd).read()
# print("copy")
# cmd2 = 'wsl.exe -d ' + str(machine) + ' cp ~/.scanapps ' + str(pat_con(script[:-15]))
# subprocess.getoutput(cmd2)
# print("read")
# try:
# read = open(script[:-15] + ".scanapps", "r").read()
# except:
# return {}
read = read.split("/:/")
read[:] = (value for value in read if value != "\n")
apps = {}
for app in read:
if "Name" in app:
if "screensaver" in app:
continue
ind = app.index(":cmd:")
name = app[5:ind]
if "#GenericName=" in name:
name = name[:name.index("#GenericName=") - 1]
elif "GenericName=" in name:
name = name[:name.index("GenericName=") - 1]
elif "Name=" in name:
name = name[:name.index("Name=") - 1]
run = app[ind + 10:]
if "Exec=" in run:
run = run[:run.index("Exec=") - 1]
if ":ico:" in run:
run = run[:run.index(":ico:")]
if "%" in run:
run = run[:run.index("%") - 1]
if "Icon=" in app:
icon = app[app.index(":ico:") + 10:]
else:
icon = None
apps.update({name: {"cmd": run, "ico": icon}})
return apps
def gtk(machine, scale):
if scale == 1 or scale == 2:
cmd = 'wsl.exe -d ' + str(machine) + ' "' + str(pat_con(script)) + '" gtk' + str(scale)
print(os.popen(cmd).read()[:-1])
def dbus(machine):
cmd = 'wsl.exe -d ' + str(machine) + ' "' + str(pat_con(script)) + '" dbus'
print(os.popen(cmd).read()[:-1])
def qt(machine, scale):
if scale == 1 or scale == 2:
cmd = 'wsl.exe -d ' + str(machine) + ' "' + str(pat_con(script)) + '" qt' + str(scale)
print(os.popen(cmd).read()[:-1])
def export(machine, version):
if version == 1 or version == 2:
cmd = 'wsl.exe -d ' + str(machine) + ' "' + str(pat_con(script)) + '" export' + str(version)
print(os.popen(cmd).read()[:-1])
def profile(machine):
cmd = 'wsl.exe -d ' + str(machine) + ' "' + str(pat_con(script)) + '" profile'
return os.popen(cmd).read()