Update fileicon to latest version

This commit is contained in:
Mbucari 2023-03-02 19:40:38 -07:00
parent 26c60e8e79
commit 174b0c26b8

View File

@ -12,7 +12,7 @@
kTHIS_NAME=${BASH_SOURCE##*/} kTHIS_NAME=${BASH_SOURCE##*/}
kTHIS_HOMEPAGE='https://github.com/mklement0/fileicon' kTHIS_HOMEPAGE='https://github.com/mklement0/fileicon'
kTHIS_VERSION='v0.3.2' # NOTE: This assignment is automatically updated by `make version VER=<newVer>` - DO keep the 'v' prefix. kTHIS_VERSION='v0.3.3' # NOTE: This assignment is automatically updated by `make version VER=<newVer>` - DO keep the 'v' prefix.
unset CDPATH # To prevent unpredictable `cd` behavior. unset CDPATH # To prevent unpredictable `cd` behavior.
@ -85,7 +85,7 @@ printUsage() {
case $1 in case $1 in
--version) --version)
# Output version number and exit, if requested. # Output version number and exit, if requested.
ver="v0.3.2"; echo "$kTHIS_NAME $kTHIS_VERSION"$'\nFor license information and more, visit '"$kTHIS_HOMEPAGE"; exit 0 ver="v0.3.3"; echo "$kTHIS_NAME $kTHIS_VERSION"$'\nFor license information and more, visit '"$kTHIS_HOMEPAGE"; exit 0
;; ;;
-h|--help) -h|--help)
# Print usage information and exit. # Print usage information and exit.
@ -116,7 +116,7 @@ esac
# IMPORTANT: Hex. digits > 9 use UPPPERCASE characters. # IMPORTANT: Hex. digits > 9 use UPPPERCASE characters.
# getAttribByteString <file> <attrib_name> # getAttribByteString <file> <attrib_name>
getAttribByteString() { getAttribByteString() {
xattr -px "$2" "$1" | tr -d ' \n' /usr/bin/xattr -px "$2" "$1" | tr -d ' \n'
return ${PIPESTATUS[0]} return ${PIPESTATUS[0]}
} }
@ -173,7 +173,7 @@ patchByteInByteString() {
# hasAttrib <fileOrFolder> <attrib_name> # hasAttrib <fileOrFolder> <attrib_name>
hasAttrib() { hasAttrib() {
xattr "$1" | /usr/bin/grep -Fqx "$2" /usr/bin/xattr "$1" | /usr/bin/grep -Fqx "$2"
} }
# hasIconData <file> # hasIconData <file>
@ -354,9 +354,9 @@ removeCustomIcon() {
if hasAttrib "$fileOrFolder" com.apple.FinderInfo; then if hasAttrib "$fileOrFolder" com.apple.FinderInfo; then
byteStr=$(getAttribByteString "$fileOrFolder" com.apple.FinderInfo | patchByteInByteString $kFI_BYTEOFFSET_CUSTOMICON '~'$kFI_VAL_CUSTOMICON) || return byteStr=$(getAttribByteString "$fileOrFolder" com.apple.FinderInfo | patchByteInByteString $kFI_BYTEOFFSET_CUSTOMICON '~'$kFI_VAL_CUSTOMICON) || return
if [[ $byteStr == "$kFI_BYTES_BLANK" ]]; then # All bytes cleared? Remove the entire attribute. if [[ $byteStr == "$kFI_BYTES_BLANK" ]]; then # All bytes cleared? Remove the entire attribute.
xattr -d com.apple.FinderInfo "$fileOrFolder" /usr/bin/xattr -d com.apple.FinderInfo "$fileOrFolder"
else # Update the attribute. else # Update the attribute.
xattr -wx com.apple.FinderInfo "$byteStr" "$fileOrFolder" || return /usr/bin/xattr -wx com.apple.FinderInfo "$byteStr" "$fileOrFolder" || return
fi fi
fi fi
@ -365,7 +365,7 @@ removeCustomIcon() {
rm -f "$(getFileWithIconData "$fileOrFolder")" rm -f "$(getFileWithIconData "$fileOrFolder")"
else # file -> remove the resource fork else # file -> remove the resource fork
if hasIconData "$fileOrFolder"; then if hasIconData "$fileOrFolder"; then
xattr -d com.apple.ResourceFork "$fileOrFolder" /usr/bin/xattr -d com.apple.ResourceFork "$fileOrFolder"
fi fi
fi fi