added opt path

This commit is contained in:
Maxim Stewart 2020-07-05 17:42:28 -05:00
parent 868b075bd5
commit af81743c2e
1 changed files with 57 additions and 43 deletions

View File

@ -27,8 +27,8 @@ class Main(Context):
while True: while True:
self.clear() self.clear()
if not self.menuData: if not self.menuData:
HOME = os.path.expanduser('~') + "/.local/share/applications/" HOME_APPS = os.path.expanduser('~') + "/.local/share/applications/"
paths = ["/usr/share/applications/", HOME] paths = ["/opt/", "/usr/share/applications/", HOME_APPS]
self.menuData = self.getDesktopFilesInfo(paths) self.menuData = self.getDesktopFilesInfo(paths)
group = self.call_method("mainMenu")["group"] group = self.call_method("mainMenu")["group"]
@ -68,53 +68,66 @@ class Main(Context):
} }
for path in paths: for path in paths:
for f in listdir(path): if not "/opt/" in path:
fPath = path + f self.listAndUpdateDesktopFiles(path, menuObjs);
flags = ["mimeinfo.cache", "defaults.list"] else:
if not f in flags and isfile(fPath): for folder in listdir(path):
xdgObj = DesktopEntry(fPath) try:
fPath = path + folder
title = xdgObj.getName() self.listAndUpdateDesktopFiles(fPath, menuObjs);
groups = xdgObj.getCategories() except Exception as e:
comment = xdgObj.getComment() self.logger.debug(e)
# icon = xdgObj.getIcon()
mainExec = xdgObj.getExec()
tryExec = xdgObj.getTryExec()
group = ""
if "Accessories" in groups or "Utility" in groups:
group = "Accessories"
elif "Multimedia" in groups or "Video" in groups or "Audio" in groups:
group = "Multimedia"
elif "Development" in groups:
group = "Development"
elif "Game" in groups:
group = "Game"
elif "Internet" in groups or "Network" in groups:
group = "Internet"
elif "Graphics" in groups:
group = "Graphics"
elif "Office" in groups:
group = "Office"
elif "System" in groups:
group = "System"
elif "Settings" in groups:
group = "Settings"
elif "Wine" in groups:
group = "Wine"
else:
group = "Other"
menuObjs[group].append( {"title": title, "groups": groups,
"comment": comment, "exec": mainExec,
"tryExec": tryExec, "fileName": f
})
return menuObjs return menuObjs
def listAndUpdateDesktopFiles(self, path, menuObjs):
for f in listdir(path):
fPath = path + f
flags = ["mimeinfo.cache", "defaults.list"]
if not f in flags and isfile(fPath):
xdgObj = DesktopEntry(fPath)
title = xdgObj.getName()
groups = xdgObj.getCategories()
comment = xdgObj.getComment()
# icon = xdgObj.getIcon()
mainExec = xdgObj.getExec()
tryExec = xdgObj.getTryExec()
group = ""
if "Accessories" in groups or "Utility" in groups:
group = "Accessories"
elif "Multimedia" in groups or "Video" in groups or "Audio" in groups:
group = "Multimedia"
elif "Development" in groups:
group = "Development"
elif "Game" in groups:
group = "Game"
elif "Internet" in groups or "Network" in groups:
group = "Internet"
elif "Graphics" in groups:
group = "Graphics"
elif "Office" in groups:
group = "Office"
elif "System" in groups:
group = "System"
elif "Settings" in groups:
group = "Settings"
elif "Wine" in groups:
group = "Wine"
else:
group = "Other"
menuObjs[group].append( {"title": title, "groups": groups,
"comment": comment, "exec": mainExec,
"tryExec": tryExec, "fileName": f
})
def getSubgroup(self, group, query = ""): def getSubgroup(self, group, query = ""):
""" """
# TODO:
Need to refactor and pull out the sub logic that is used in both cases... Need to refactor and pull out the sub logic that is used in both cases...
""" """
desktopObjs = [] desktopObjs = []
@ -145,6 +158,7 @@ class Main(Context):
def executeProgram(self, group, entry): def executeProgram(self, group, entry):
""" """
# TODO:
Need to refactor and pull out the sub loop that is used in both cases... Need to refactor and pull out the sub loop that is used in both cases...
""" """
parts = entry.split("||") parts = entry.split("||")