diff --git a/.gitignore b/.gitignore index 592ed6b..d3cac00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -/Polymain.iconset -/Polymail.icns +/Polymail.iconset diff --git a/Icon1024.png b/Icon1024.png deleted file mode 100644 index aefb684..0000000 Binary files a/Icon1024.png and /dev/null differ diff --git a/Icon1024.svg b/Icon1024.svg new file mode 100644 index 0000000..716a51a --- /dev/null +++ b/Icon1024.svg @@ -0,0 +1,40 @@ + + + Icon1024 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Icon64.png b/Icon64.png deleted file mode 100644 index f398bfe..0000000 Binary files a/Icon64.png and /dev/null differ diff --git a/Icon64.svg b/Icon64.svg new file mode 100644 index 0000000..cbc6903 --- /dev/null +++ b/Icon64.svg @@ -0,0 +1,40 @@ + + + Icon64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c16e11d --- /dev/null +++ b/Makefile @@ -0,0 +1,43 @@ +INKSCAPE=$(shell which inkscape) + +define print_header +@echo +@echo "==> $(1)" +@echo +endef + +define svg_to_png +@$(INKSCAPE) -z -e $(CURDIR)/$1/$(2).png -w $(3) -h $(3) $(CURDIR)/$(4) 1>/dev/null +@echo "convert $(4) to $(2).png" + +endef + +define convert +$(call svg_to_png,$(1),icon_$(2)x$(2),$(2),$(3)) +$(call svg_to_png,$(1),icon_$(2)x$(2)@2x,$(shell echo $$(($2*2))),$(3)) + +endef + +all: build install clean + +Polymail.icns: Polymail.iconset + $(call print_header,"Create icon resource") + rm -f Polymail.icns + iconutil -c icns -o $@ $^ + +Polymail.iconset: + $(call print_header,"Convert svg to pngs") + mkdir -p $@ + $(foreach size,16 32,$(call convert,$@,$(size),Icon64.svg)) + $(foreach size,128 256 512,$(call convert,$@,$(size),Icon1024.svg)) + +build: clean Polymail.icns + +clean: + rm -rf Polymail.iconset + +install: + $(call print_header,"Install icns") + ./install.sh Polymail.icns + +.PHONY: all build clean install diff --git a/Polymail.icns b/Polymail.icns new file mode 100644 index 0000000..0fd6f43 Binary files /dev/null and b/Polymail.icns differ diff --git a/Polymail.svg b/Polymail.svg deleted file mode 100644 index d69281f..0000000 --- a/Polymail.svg +++ /dev/null @@ -1,26 +0,0 @@ - - - Polymail.app alternative icon - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..aa681c9 --- /dev/null +++ b/install.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# Exit on errors +set -o errexit +set -o nounset + +# Constants +URL=https://raw.githubusercontent.com/Greenek/polymail.icns/master/Polymail.icns + +# Check if operating system is supported +if [[ $OSTYPE != "darwin"* ]]; then + echo "This script requires OSX system to run." + exit 1 +fi + +# Check if Polymail.app is installed +: ${POLYMAIL_PATH:="/Applications/Polymail.app"} + +if [ ! -d "$POLYMAIL_PATH" ]; then + echo "Polymail.app not found." + exit 1 +fi + +# Initialize temporary files paths +TMPICNS=$TMPDIR"Polymail.icns" +TMPRSRC=$TMPDIR"icon.rsrc" + +if [ $# -eq 0 ]; then + # Download icon file if path has not been passed in argument + curl -L -o $TMPICNS $URL +else + cp -f $1 $TMPICNS +fi + +# Add icon to image file +sips -i $TMPICNS >> /dev/null + +# Take icon and put into a rsrc file +DeRez -only icns $TMPICNS > $TMPRSRC + +# Apply the rsrc file +SetFile -a C $POLYMAIL_PATH + +# Remove old resource +rm -f $POLYMAIL_PATH/Icon? + +# Append icon resource +Rez $TMPRSRC -o $POLYMAIL_PATH/$'Icon\r' +SetFile -a V $POLYMAIL_PATH/Icon? + +# Clean +rm $TMPRSRC $TMPICNS + +# Success output +cat << EOF +New icon for Polymail.app has been successfully installed. + +TO COMPLETE INSTALLATION: + +1) Restart application + +or + +2) Clear system icon cache + +sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \; +sudo find /private/var/folders -name com.apple.iconservices -exec rm -rf {} \; +killall Dock +EOF diff --git a/make.sh b/make.sh deleted file mode 100755 index e5547e2..0000000 --- a/make.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $DIR - -ICONSET="Polymail.iconset" - -ICONSMALL="Icon64.png" -ICONLARGE="Icon1024.png" - -rm -rf $ICONSET && mkdir $ICONSET - -sips -z 16 16 $ICONSMALL --out $ICONSET/icon_16x16.png -sips -z 32 32 $ICONSMALL --out $ICONSET/icon_16x16@2x.png -sips -z 32 32 $ICONSMALL --out $ICONSET/icon_32x32.png -sips -z 64 64 $ICONSMALL --out $ICONSET/icon_32x32@2x.png -sips -z 128 128 $ICONLARGE --out $ICONSET/icon_128x128.png -sips -z 256 256 $ICONLARGE --out $ICONSET/icon_128x128@2x.png -sips -z 256 256 $ICONLARGE --out $ICONSET/icon_256x256.png -sips -z 512 512 $ICONLARGE --out $ICONSET/icon_256x256@2x.png -sips -z 512 512 $ICONLARGE --out $ICONSET/icon_512x512.png -cp $ICONLARGE $ICONSET/icon_512x512@2x.png - -iconutil -c icns $ICONSET - -rm -R $ICONSET