diff --git a/fake_home/.rofi-list-git-repos.py b/fake_home/.rofi-list-git-repos.py index 4a3df10..b6bf9ad 100755 --- a/fake_home/.rofi-list-git-repos.py +++ b/fake_home/.rofi-list-git-repos.py @@ -21,25 +21,29 @@ def get_application_desktop_file_info(application: str, prefix: str) -> str: return line -def get_project_type(project) -> str: +def get_project_type(project) -> (str, str): + ret = ("idea", None) for file in os.listdir(project): if file.endswith("pom.xml"): - return "idea" + return ("idea", None) if file.endswith("package.json"): - return "webstorm" + return ("webstorm", None) if file.endswith("cargo.toml") or file.endswith(".c"): - return "clion" - if file.endswith(".csproj") or file.endswith("DotSettings"): - return "rider" + return ("clion", None) + if file.endswith(".csproj"): + return ("rider", file) + if file.endswith("DotSettings"): + # Allow .csproj to override this value + ret = ("rider", None) if file.endswith(".py"): - return "pycharm" + return ("pycharm", None) if file.endswith(".go"): - return "goland" - return "idea" + return ("goland", None) + return ret def get_icon(project: str) -> str | None: - project_type = get_project_type(project) + (project_type, _) = get_project_type(project) if project_type is None: return None icon_line = get_application_desktop_file_info(project_type, 'Icon') @@ -47,9 +51,12 @@ def get_icon(project: str) -> str | None: def open_project(project: str) -> (): - project_type = get_project_type(project) + (project_type, file) = get_project_type(project) if project_type is None: return + if file is not None: + project = f'{project}/{file}' + command = get_application_desktop_file_info(project_type, 'Exec')[6:-5] subprocess.Popen([command + " " + project], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)