diff --git a/fake_home/.rofi-list-git-repos.py b/fake_home/.rofi-list-git-repos.py index b6bf9ad..bb8a7cb 100755 --- a/fake_home/.rofi-list-git-repos.py +++ b/fake_home/.rofi-list-git-repos.py @@ -1,23 +1,30 @@ #!/usr/bin/python3 -# This is a sample Python script. - -# Press Shift+F10 to execute it or replace it with your code. -# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. import os import subprocess import sys home = os.environ['HOME'] -git_dirs = [home + "/work", home + "/projects", home + "/git", home + "/WebStormProjects", home + "/RiderProjects"] +git_dirs = [ + home + "/work", + home + "/projects", + home + "/git", + home + "/WebStormProjects", + home + "/RiderProjects" +] + + icons = {} - - def get_application_desktop_file_info(application: str, prefix: str) -> str: + existing_key = prefix + application + existing = icons.get(existing_key) + if existing is not None: + return existing path = f"{home}/.local/share/applications/jetbrains-{application}.desktop" with open(path, 'r') as file: for line in file.readlines(): if line.startswith(prefix): + icons[existing_key] = line return line @@ -62,12 +69,11 @@ def open_project(project: str) -> (): def print_project_message(project: str) -> (): - # exe=$(grep "Exec" "$HOME/.local/share/applications/jetbrains-$application.desktop" | sed 's/.*"\([^"]*\)".*/\1/') icon = get_icon(project) if icon is None: return - print(f'{project}\0icon\x1f{get_icon(project)}') + print(f'{project}\0icon\x1f{icon}') if __name__ == '__main__':