diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/Info.plist b/Info.plist new file mode 100644 index 0000000..a236df7 --- /dev/null +++ b/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleName + mxd + CFBundleDisplayName + mxd + CFBundleIdentifier + dev.yigid.mxd + CFBundleExecutable + mxd + CFBundlePackageType + APPL + CFBundleIconFile + mxd + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1.0 + CFBundleInfoDictionaryVersion + 6.0 + LSUIElement + + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6411799 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +SIGN_ID ?= - +ICTOOL ?= /Applications/Icon Composer.app/Contents/Executables/ictool +LABEL = dev.yigid.mxd +BUILD_DIR = build +BUNDLE = $(BUILD_DIR)/mxd.app +ICONSET = $(BUILD_DIR)/mxd.iconset +INSTALLED_BUNDLE = $(HOME)/Applications/mxd.app +LAUNCH_AGENT = $(HOME)/Library/LaunchAgents/$(LABEL).plist + +.PHONY: app icon install uninstall clean + +app: + mkdir -p $(BUILD_DIR) + swiftc -O -swift-version 5 mxd.swift -o $(BUILD_DIR)/mxd + rm -rf $(BUNDLE) + mkdir -p $(BUNDLE)/Contents/MacOS $(BUNDLE)/Contents/Resources + cp Info.plist $(BUNDLE)/Contents/Info.plist + cp $(BUILD_DIR)/mxd $(BUNDLE)/Contents/MacOS/mxd + cp mxd.icns $(BUNDLE)/Contents/Resources/mxd.icns + codesign --force --sign "$(SIGN_ID)" --identifier $(LABEL) $(BUNDLE) + +icon: + rm -rf $(ICONSET) + mkdir -p $(ICONSET) + for base in 16 32 128 256 512; do \ + for scale in 1 2; do \ + canvas=$$((base * scale)); \ + tile=$$(( (canvas * 824 + 512) / 1024 )); \ + if [ $$scale -eq 1 ]; then name=icon_$${base}x$${base}.png; else name=icon_$${base}x$${base}@2x.png; fi; \ + "$(ICTOOL)" mxd.icon --export-image --output-file $(ICONSET)/$$name --platform macOS --rendition Default --width $$tile --height $$tile --scale 1 > /dev/null || exit 1; \ + sips --padToHeightWidth $$canvas $$canvas $(ICONSET)/$$name > /dev/null || exit 1; \ + done; \ + done + iconutil --convert icns --output mxd.icns $(ICONSET) + +install: app + -launchctl bootout gui/$$(id -u)/$(LABEL) + mkdir -p $(HOME)/Applications $(HOME)/Library/LaunchAgents $(HOME)/Library/Logs + rm -rf $(INSTALLED_BUNDLE) + ditto $(BUNDLE) $(INSTALLED_BUNDLE) + sed "s|__HOME__|$(HOME)|g" $(LABEL).plist > $(LAUNCH_AGENT) + launchctl bootstrap gui/$$(id -u) $(LAUNCH_AGENT) + +uninstall: + -launchctl bootout gui/$$(id -u)/$(LABEL) + rm -rf $(INSTALLED_BUNDLE) + rm -f $(LAUNCH_AGENT) + +clean: + rm -rf $(BUILD_DIR) diff --git a/dev.yigid.mxd.plist b/dev.yigid.mxd.plist new file mode 100644 index 0000000..a8d2fbd --- /dev/null +++ b/dev.yigid.mxd.plist @@ -0,0 +1,27 @@ + + + + + Label + dev.yigid.mxd + ProgramArguments + + __HOME__/Applications/mxd.app/Contents/MacOS/mxd + + AssociatedBundleIdentifiers + + dev.yigid.mxd + + RunAtLoad + + KeepAlive + + SuccessfulExit + + + ProcessType + Interactive + StandardErrorPath + __HOME__/Library/Logs/mxd.log + + diff --git a/mxd.icns b/mxd.icns new file mode 100644 index 0000000..ddae692 Binary files /dev/null and b/mxd.icns differ