From 5b9a44ed6e3484e824a43dbbeb95f369338e2af0 Mon Sep 17 00:00:00 2001 From: B Stack Date: Thu, 20 Jun 2019 16:42:04 -0400 Subject: tcl: add backup icon themes, and full svg support The svg-checking logic should be complete. Also, the program now checks alternate themes (hard-coded) in case the selected theme does not have the requested icon. --- logout-manager-tcl.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/logout-manager-tcl.py b/logout-manager-tcl.py index cc3b2fb..8daf66d 100755 --- a/logout-manager-tcl.py +++ b/logout-manager-tcl.py @@ -253,13 +253,30 @@ def get_filename_of_icon(name, theme = "hicolor", size = 48, category = "actions print("Finding filename of icon, theme=",theme,"category=",category,"name=",name) # to exclude the scalable/ contents, replace dir 5 asterisk with [0-9]* results = [] + base_dir="/usr/share/icons/" file_filters = ".*" if LM_USE_SVG == 0: file_filters = ".{png,PNG}" - results = glob.glob("/usr/share/icons/"+theme+"/*/"+category+"/"+name+file_filters) + # I have no idea if this is xdg icon theme compliant, but it is a valiant attempt. + # 1. try (requested) req-theme, req-category, req-name first + results = glob.glob(base_dir+theme+"/*/"+category+"/"+name+file_filters) + # 2. try req-theme, (generic) gen-category, req-name if len(results) == 0: # no results with that category, so try all categories - results = glob.glob("/usr/share/icons/"+theme+"/*/*/"+name+file_filters) + results = glob.glob(base_dir+theme+"/*/*/"+name+file_filters) + # 3. try "gnome", req-category, req-name + if len(results) == 0: + results = glob.glob(base_dir+"gnome"+"/*/"+category+"/"+name+file_filters) + # 4. try "gnome", gen-category, req-name + if len(results) == 0: + results = glob.glob(base_dir+"gnome"+"/*/*/"+name+file_filters) + # 5. try "hicolor", req-category, req-name + if len(results) == 0: + results = glob.glob(base_dir+"hicolor"+"/*/"+category+"/"+name+file_filters) + # 6. try "hicolor", gen-category, req-name + if len(results) == 0: + results = glob.glob(base_dir+"hicolor"+"/*/*/"+name+file_filters) + # the sort arranges it so a Numix/24 dir comes before a Numix/24@2x dir results = sorted(results, key=sort_sizes) #print(results) -- cgit