From 868b075bd5ca81288fc8a42458a1cb2b55d5adf3 Mon Sep 17 00:00:00 2001 From: Maxim Stewart Date: Sat, 25 Apr 2020 02:22:56 -0500 Subject: [PATCH] added quick launch script, edited paths --- src/__init__.py | 84 +++++++++++++++++++++++---------------------- src/core/Context.py | 4 +-- src/shellmen | 13 +++++++ 3 files changed, 58 insertions(+), 43 deletions(-) create mode 100755 src/shellmen diff --git a/src/__init__.py b/src/__init__.py index e494e44..4d9ea3f 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -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 diff --git a/src/core/Context.py b/src/core/Context.py index 2b591e8..45f7645 100644 --- a/src/core/Context.py +++ b/src/core/Context.py @@ -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): diff --git a/src/shellmen b/src/shellmen new file mode 100755 index 0000000..507bcae --- /dev/null +++ b/src/shellmen @@ -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 $@;