- when icon is not found in hicolor theme, search for in in other themes - added -follow to find
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
set -e
 | 
						|
read filename
 | 
						|
 | 
						|
if [[ "${filename}" = xdgicon:* ]]; then
 | 
						|
    # get biggest icon from hicolor theme
 | 
						|
 | 
						|
    filename="${filename#*:}.png"
 | 
						|
    candidate=
 | 
						|
    for dir in /usr/share/icons/{hicolor/,}; do
 | 
						|
        candidate=$(find -L "${dir}" -type f -name "${filename}")
 | 
						|
        if [[ -n "${candidate}" ]]; then
 | 
						|
            candidate=$(echo "${candidate}" | xargs ls --sort=size | head -1)
 | 
						|
            break
 | 
						|
        fi
 | 
						|
    done
 | 
						|
 | 
						|
    [[ -n "${candidate}" ]]
 | 
						|
    filename="${candidate}"
 | 
						|
 | 
						|
elif [[ "${filename}" = "-" ]] || [[ "${filename}" = *":-" ]]; then
 | 
						|
    tmpfile="$(mktemp /tmp/qimg-XXXXXXXX)"
 | 
						|
    cat > "${tmpfile}"
 | 
						|
    if [[ "$filename" = *":-" ]]; then
 | 
						|
        tmpfile="${filename%:*}:${tmpfile}"
 | 
						|
    fi
 | 
						|
    filename="${tmpfile}"
 | 
						|
 | 
						|
elif ! [[ -r "${filename}" ]]; then
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
# identify in F18 (6.7) adds implicit '\n' to format,
 | 
						|
# whereas identify in F20 (6.8) does not
 | 
						|
identify -format '%w %h\n' "$filename" | sed -e '/^$/d'
 | 
						|
convert -depth 8 "$filename" rgba:-
 | 
						|
 | 
						|
[[ -n "${tmpfile}" ]] && rm -f ${tmpfile} || true
 | 
						|
 | 
						|
# vim: ft=sh ts=4 sw=4 et
 |