diff options
author | B Stack <bgstack15@gmail.com> | 2019-06-20 16:42:04 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2019-06-20 16:42:04 -0400 |
commit | 5b9a44ed6e3484e824a43dbbeb95f369338e2af0 (patch) | |
tree | debc36611c42cd4ce86cd58609d6a689f231207e | |
parent | just use an empty icon if not resolvable (diff) | |
download | logout-manager-5b9a44ed6e3484e824a43dbbeb95f369338e2af0.tar.gz logout-manager-5b9a44ed6e3484e824a43dbbeb95f369338e2af0.tar.bz2 logout-manager-5b9a44ed6e3484e824a43dbbeb95f369338e2af0.zip |
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.
-rwxr-xr-x | logout-manager-tcl.py | 21 |
1 files 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) |