1600+ icons a thing I did
Not icon contribution and not an issue but I created this to help me find icons for dashy
-------------------------------- code below this line - name as search_icon.py on linux ignore the copy buttons - copy from below to the next dotted line.
#!/usr/bin/env python3 import os import sys import difflib import subprocess
ICONS_SUBDIR = "svg" MAX_RESULTS = 10 CUTOFF = 0.4
def run(cmd): return subprocess.check_output(cmd, text=True).strip()
def repo_status(): try: local = run(["git", "rev-parse", "HEAD"]) remote = run(["git", "ls-remote", "origin", "HEAD"]).split()[0] base = run(["git", "merge-base", "HEAD", "origin/HEAD"])
if local == remote:
return ("up_to_date", local, remote)
elif local == base:
return ("behind", local, remote)
elif remote == base:
return ("ahead", local, remote)
else:
return ("diverged", local, remote)
except Exception:
return ("unknown", None, None)def maybe_update_repo(): status, local, remote = repo_status()
if status == "up_to_date":
print("✅ Repo is up to date.\n")
return
if status == "behind":
print("⚠️ Repo is behind origin.")
print(f" local : {local}")
print(f" remote: {remote}")
choice = input("Pull latest with 'git pull --rebase'? [y/N] ").strip().lower()
if choice == "y":
try:
subprocess.check_call(["git", "pull", "--rebase"])
print("✅ Updated repo.\n")
except subprocess.CalledProcessError as e:
print(f"❌ Pull failed: {e}")
else:
print("⏭ Skipping update.\n")
return
if status == "ahead":
print("ℹ️ Repo is ahead of origin (local commits exist).\n")
return
if status == "diverged":
print("⚠️ Repo has diverged from origin, manual fix needed.\n")
return
print("❓ Couldn't determine repo status.\n")def load_slugs(repo_root): icons_path = os.path.join(repo_root, ICONS_SUBDIR) slugs = [] for root, dirs, files in os.walk(icons_path): for f in files: if f.endswith(".svg"): slug = f[:-4] slugs.append((slug, os.path.join(root, f))) return slugs
def rank_matches(search_term, slugs): term = search_term.lower()
names_only = [s[0] for s in slugs]
exact = []
prefix = []
contains = []
fuzzy = []
for slug, path in slugs:
s = slug.lower()
if s == term:
exact.append((slug, path))
elif s.startswith(term):
prefix.append((slug, path))
elif term in s:
contains.append((slug, path))
close_names = difflib.get_close_matches(term, names_only, n=MAX_RESULTS, cutoff=CUTOFF)
for slug, path in slugs:
if slug in close_names:
fuzzy.append((slug, path))
ordered = []
seen = set()
for bucket in (exact, prefix, contains, fuzzy):
for slug, path in bucket:
if slug not in seen:
ordered.append((slug, path))
seen.add(slug)
return ordered[:MAX_RESULTS], exactdef main(): if len(sys.argv) < 2: print("Usage: search_icon.py ") sys.exit(1)
term = sys.argv[1]
# 1. sync check
maybe_update_repo()
# 2. load icons
repo_root = os.path.dirname(os.path.abspath(__file__))
slugs = load_slugs(repo_root)
# 3. rank candidates + capture exact matches
matches, exact_matches = rank_matches(term, slugs)
# 4. output
print(f"Search term: {term}")
if not matches:
print("No matches found.")
sys.exit(0)
print("Potential matches (best first):")
for slug, path in matches:
print(f" - {slug:<25} => file: {path}")
print("\nDashy icon value examples:")
for slug, _ in matches[:5]:
print(f" icon: hl-{slug}")
# 5. if we got exact filename hit, call it out explicitly
if exact_matches:
# There should only really be one, but we'll handle plural just in case
print("\nExact match:")
for slug, _ in exact_matches:
print(f" icon: hl-{slug} # perfect match")if name == "main": main()
-------------------------------- code ends here (the post didn't like me doing it properly
what does it do? check the repo is up todate - if not pull it fuzzy search for your icon usage example -
./search_icon.py influxdb ✅ Repo is up to date.
Search term: influxdb Potential matches (best first):
- influxdb => file: /home/pi/dashboard-icons/svg/influxdb.svg
- runonflux => file: /home/pi/dashboard-icons/svg/runonflux.svg
- miniflux => file: /home/pi/dashboard-icons/svg/miniflux.svg
- icloud => file: /home/pi/dashboard-icons/svg/icloud.svg
- fluidd => file: /home/pi/dashboard-icons/svg/fluidd.svg
- linuxdo => file: /home/pi/dashboard-icons/svg/linuxdo.svg
- miniflux-light => file: /home/pi/dashboard-icons/svg/miniflux-light.svg
- flux-cd => file: /home/pi/dashboard-icons/svg/flux-cd.svg
- netflix => file: /home/pi/dashboard-icons/svg/netflix.svg
- linux => file: /home/pi/dashboard-icons/svg/linux.svg
Dashy icon value examples: icon: hl-influxdb icon: hl-runonflux icon: hl-miniflux icon: hl-icloud icon: hl-fluidd
Exact match: icon: hl-influxdb # perfect match
Source: homarr-labs/dashboard-icons