diff --git a/share/set_icon.sh b/share/set_icon.sh new file mode 100755 index 0000000..0581d67 --- /dev/null +++ b/share/set_icon.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Based on https://stackoverflow.com/a/8375093 +# TODO: Rez, DeRez and SetFile are deprecated, but I have not yet found replacement tools +# Sets an icon on file or directory +# Usage setIcon.sh iconimage.jpg /path/to/[file|folder] +iconSource=$1 +iconDestination=$2 +icon=/tmp/`basename $iconSource` +rsrc=/tmp/juci.rsrc + +# Create icon from the iconSource +cp $iconSource $icon + +# Add icon to image file, meaning use itself as the icon +sips -i $icon > /dev/null + +# Take that icon and put it into a rsrc file +DeRez -only icns $icon > $rsrc + +# Apply the rsrc file to +SetFile -a C $iconDestination + +# Append resource to the file you want to icon-ize. +Rez -append $rsrc -o $iconDestination + +rm $rsrc $icon diff --git a/share/set_icon_macos.py b/share/set_icon_macos.py deleted file mode 100644 index 3a55a5e..0000000 --- a/share/set_icon_macos.py +++ /dev/null @@ -1,4 +0,0 @@ -import Cocoa -import sys - -Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(Cocoa.NSImage.alloc().initWithContentsOfFile_(sys.argv[1].decode('utf-8')), sys.argv[2].decode('utf-8'), 0) or sys.exit("Unable to set file icon") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1612307..c567d1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,7 +73,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES Linux|.*BSD|DragonFly) install(FILES "${CMAKE_SOURCE_DIR}/share/juci.svg" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps") elseif(APPLE) - install(CODE "execute_process(COMMAND /usr/bin/python ${CMAKE_SOURCE_DIR}/share/set_icon_macos.py ${CMAKE_SOURCE_DIR}/share/juci.png ${CMAKE_INSTALL_PREFIX}/bin/juci)") + install(CODE "execute_process(COMMAND ${CMAKE_SOURCE_DIR}/share/set_icon.sh ${CMAKE_SOURCE_DIR}/share/juci.png ${CMAKE_INSTALL_PREFIX}/bin/juci)") endif() # add a target to generate API documentation with Doxygen