missingIconsFinder: init
This commit is contained in:
69
missingIconsFinder/find_missing_icons.py
Executable file
69
missingIconsFinder/find_missing_icons.py
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i python3 -p python3
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
from collections import defaultdict
|
||||
|
||||
# nix-locate -r "share/icons/hicolor/[^/]+/apps/.*\.*" --all | awk '{print substr($4, length($4) - 3 + 1)}' | sort -u
|
||||
ICON_SUFFIXES = [
|
||||
'bmp',
|
||||
'cns',
|
||||
'eep',
|
||||
'gif',
|
||||
'ico',
|
||||
'jpeg',
|
||||
'jpg',
|
||||
'nse',
|
||||
'png',
|
||||
'svg',
|
||||
'vgz',
|
||||
'xpm',
|
||||
]
|
||||
|
||||
ICON_SUFFIXES += [x.upper() for x in ICON_SUFFIXES]
|
||||
|
||||
LOCATE_REGEX = f'share/(applications/[^/]+\\.desktop|icons/hicolor/[^/]+/apps/[^/]+\\.({'|'.join(ICON_SUFFIXES)}))'
|
||||
|
||||
result = subprocess.run(['nix-locate', '-r', LOCATE_REGEX, '--all'], capture_output=True)
|
||||
|
||||
results = []
|
||||
for x in result.stdout.split(b"\n"):
|
||||
try:
|
||||
drv, size, type, path = x.split()
|
||||
results.append({
|
||||
'drv': drv.decode(),
|
||||
'size': size.decode(),
|
||||
'type': type.decode(),
|
||||
'path': path.decode(),
|
||||
})
|
||||
except:
|
||||
pass
|
||||
|
||||
results_by_package = defaultdict(list)
|
||||
for x in results:
|
||||
results_by_package[x['drv']].append({
|
||||
'size': x['size'],
|
||||
'type': x['type'],
|
||||
'path': x['path'],
|
||||
})
|
||||
|
||||
def ends_with_image_suffix(str) -> bool:
|
||||
return any(str.endswith(suf) for suf in ICON_SUFFIXES)
|
||||
|
||||
results_by_package_without_icons = { }
|
||||
for drv, v in results_by_package.items():
|
||||
if any(x['path'].endswith('.desktop') for x in v) and not any(ends_with_image_suffix(x['path']) for x in v):
|
||||
results_by_package_without_icons[drv] = v
|
||||
|
||||
def print_result(drv, v):
|
||||
print(f"{drv}:")
|
||||
for x in v:
|
||||
p = re.sub(r'^/nix/store/[^/]+/', '', x['path'])
|
||||
print(f" {x['type']} {p} ({x['size']})")
|
||||
print("")
|
||||
|
||||
for drv, v in results_by_package_without_icons.items():
|
||||
print_result(drv, v)
|
||||
|
||||
print(f'COUNT: {len(results_by_package_without_icons)}')
|
||||
Reference in New Issue
Block a user