added quick launch script, edited paths

This commit is contained in:
Maxim Stewart 2020-04-25 02:22:56 -05:00
parent dfe7b2bb63
commit 868b075bd5
3 changed files with 58 additions and 43 deletions

View File

@ -27,8 +27,9 @@ class Main(Context):
while True:
self.clear()
if not self.menuData:
path = "/usr/share/applications/"
self.menuData = self.getDesktopFilesInfo(path)
HOME = os.path.expanduser('~') + "/.local/share/applications/"
paths = ["/usr/share/applications/", HOME]
self.menuData = self.getDesktopFilesInfo(paths)
group = self.call_method("mainMenu")["group"]
query = ""
@ -51,7 +52,7 @@ class Main(Context):
return method(data) if data else method()
def getDesktopFilesInfo(self, path):
def getDesktopFilesInfo(self, paths):
menuObjs = {
"Accessories": [],
"Multimedia": [],
@ -66,47 +67,48 @@ class Main(Context):
"Other": []
}
for path in paths:
for f in listdir(path):
fPath = path + f
flags = ["mimeinfo.cache", "defaults.list"]
if not f in flags and isfile(fPath):
xdgObj = DesktopEntry(fPath)
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()
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"
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} )
menuObjs[group].append( {"title": title, "groups": groups,
"comment": comment, "exec": mainExec,
"tryExec": tryExec, "fileName": f
})
return menuObjs

View File

@ -16,8 +16,8 @@ from .mixins import StylesMixin
GROUPS = ["[ Search ]", "Accessories", "Multimedia", "Graphics", "Game",
"Office", "Development", "Internet", "Settings",
"System", "Wine", "Other", "[ Exit ]"]
"Office", "Development", "Internet", "Settings", "System",
"Wine", "Other", "[ Exit ]"]
class Context(StylesMixin):

13
src/shellmen Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
# set -o xtrace ## To debug scripts
# set -o errexit ## To exit on error
# set -o errunset ## To exit if a variable is referenced but not set
function main() {
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cd "${SCRIPTPATH}"
python3 .
}
main $@;