29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
import os
|
|
|
|
chrootEnvPath="/opt/new-system-env"
|
|
for i in os.listdir("{}/usr/share/applications".format(chrootEnvPath)):
|
|
if os.path.exists("/usr/share/applications/gx-env-{}".format(i)):
|
|
continue
|
|
info = ""
|
|
try:
|
|
with open("{}/usr/share/applications/{}".format(chrootEnvPath, i), "r") as file:
|
|
info = file.read()
|
|
except:
|
|
try:
|
|
with open("{}/opt/apps/{}/entries/applications/{}".format(chrootEnvPath, os.path.splitext(os.path.basename(i))[0], i), "r") as file:
|
|
info = file.read()
|
|
except:
|
|
continue
|
|
newInfo = ""
|
|
for r in info.splitlines():
|
|
if "exec=" in r.lower():
|
|
newInfo += "Exec=gx-env-run " + r[5:].strip() + "\n"
|
|
elif "name=" in r.lower() or "name[" in r.lower():
|
|
newInfo += r + "(兼容模式)\n"
|
|
else:
|
|
newInfo += r + "\n"
|
|
print(newInfo)
|
|
print(i)
|
|
with open("/usr/share/applications/gx-env-{}".format(i), "w") as file:
|
|
file.write(newInfo) |