基本完成第一版
This commit is contained in:
23
gx-env-load-desktop-in-chroot
Normal file → Executable file
23
gx-env-load-desktop-in-chroot
Normal file → Executable file
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
#chrootEnvPath="/opt/new-system-env"
|
||||
@@ -11,8 +12,10 @@ if not os.path.exists("/gx-env/shell"):
|
||||
if not os.path.exists("/gx-env/icons"):
|
||||
os.makedirs("/gx-env/icons")
|
||||
for i in os.listdir("{}/usr/share/applications".format(chrootEnvPath)):
|
||||
if os.path.exists("/usr/share/applications/gx-env-{}".format(i)):
|
||||
if i == "gdebi.desktop" or i == "spark-store.desktop":
|
||||
continue
|
||||
#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:
|
||||
@@ -28,8 +31,14 @@ for i in os.listdir("{}/usr/share/applications".format(chrootEnvPath)):
|
||||
if "exec=" in r.lower():
|
||||
#newInfo += "Exec=gx-env-run " + r[5:].strip() + "\n"
|
||||
with open("/gx-env/shell/gx-env-{}.sh".format(os.path.splitext(os.path.basename(i))[0]), "w") as file:
|
||||
program = r[5:].strip()
|
||||
command = ""
|
||||
program = r[5:].strip()
|
||||
#try:
|
||||
# if sys.argv[1] == "1":
|
||||
# command += " --no-sandbox "
|
||||
#except:
|
||||
# pass
|
||||
|
||||
if "%F" in program:
|
||||
program = program.replace("%F", "$1")
|
||||
command += " %F "
|
||||
@@ -42,7 +51,13 @@ for i in os.listdir("{}/usr/share/applications".format(chrootEnvPath)):
|
||||
if "%U" in program:
|
||||
program = program.replace("%U", "$4")
|
||||
command += " %U "
|
||||
file.write("#!/bin/bash\n" + program)
|
||||
try:
|
||||
if sys.argv[1] == "1":
|
||||
file.write("#!/bin/bash\n" + program + " --no-sandbox")
|
||||
else:
|
||||
file.write("#!/bin/bash\n" + program)
|
||||
except:
|
||||
file.write("#!/bin/bash\n" + program)
|
||||
newInfo += "Exec=gx-env-run bash \"/gx-env/shell/gx-env-{}.sh\" {} \n".format(os.path.splitext(os.path.basename(i))[0], command)
|
||||
elif "name=" in r.lower() or "name[" in r.lower():
|
||||
newInfo += r + "(兼容模式)\n"
|
||||
@@ -61,4 +76,4 @@ for i in os.listdir("{}/usr/share/applications".format(chrootEnvPath)):
|
||||
print(newInfo)
|
||||
print(i)
|
||||
with open("/gx-env/desktop/gx-env-{}".format(i), "w") as file:
|
||||
file.write(newInfo)
|
||||
file.write(newInfo)
|
||||
|
||||
Reference in New Issue
Block a user