Update fileicon to latest version

This commit is contained in:
Mbucari committed 2023-03-02 19:40:38 -07:00
1 parent 26c60e8e79
commit 174b0c26b8
1 file changed
+7 -7
+7 -7
View File
@@ -12,7 +12,7 @@
kTHIS_NAME=${BASH_SOURCE##*/}
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.
@@ -85,7 +85,7 @@ printUsage() {
case $1 in
--version)
# 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)
# Print usage information and exit.
@@ -116,7 +116,7 @@ esac
# IMPORTANT: Hex. digits > 9 use UPPPERCASE characters.
# getAttribByteString <file> <attrib_name>
getAttribByteString() {
xattr -px "$2" "$1" | tr -d ' \n'
/usr/bin/xattr -px "$2" "$1" | tr -d ' \n'
return ${PIPESTATUS[0]}
}
@@ -173,7 +173,7 @@ patchByteInByteString() {
# hasAttrib <fileOrFolder> <attrib_name>
hasAttrib() {
xattr "$1" | /usr/bin/grep -Fqx "$2"
/usr/bin/xattr "$1" | /usr/bin/grep -Fqx "$2"
}
# hasIconData <file>
@@ -354,9 +354,9 @@ removeCustomIcon() {
if hasAttrib "$fileOrFolder" com.apple.FinderInfo; then
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.
xattr -d com.apple.FinderInfo "$fileOrFolder"
/usr/bin/xattr -d com.apple.FinderInfo "$fileOrFolder"
else # Update the attribute.
xattr -wx com.apple.FinderInfo "$byteStr" "$fileOrFolder" || return
/usr/bin/xattr -wx com.apple.FinderInfo "$byteStr" "$fileOrFolder" || return
fi
fi
@@ -365,7 +365,7 @@ removeCustomIcon() {
rm -f "$(getFileWithIconData "$fileOrFolder")"
else # file -> remove the resource fork
if hasIconData "$fileOrFolder"; then
xattr -d com.apple.ResourceFork "$fileOrFolder"
/usr/bin/xattr -d com.apple.ResourceFork "$fileOrFolder"
fi
fi