Icon caching and other rofi-git-repos cleanup
This commit is contained in:
parent
b0cfe40b96
commit
28a75d8a3c
|
@ -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__':
|
||||
|
|
Loading…
Reference in New Issue