From b23de86002ca92826c44ff91207cc62a996600ad Mon Sep 17 00:00:00 2001 From: Rod Yager Date: Sat, 14 Jan 2023 13:59:10 +1100 Subject: [PATCH] postinstall: Launch PDFWriter Utility with launchctl so that it has a current working directory. Otherwise showing the panel causes a crash. Utilitiy: Remove the redundant State variable from ContentView --- PDFWriter Utility/ContentView.swift | 1 - build/postinstall | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PDFWriter Utility/ContentView.swift b/PDFWriter Utility/ContentView.swift index b8af34f..7648b9e 100644 --- a/PDFWriter Utility/ContentView.swift +++ b/PDFWriter Utility/ContentView.swift @@ -8,7 +8,6 @@ import SwiftUI struct ContentView: View { - @State var filename = "Filename" var body: some View { VStack{ Spacer() diff --git a/build/postinstall b/build/postinstall index 5100efd..6809dd9 100755 --- a/build/postinstall +++ b/build/postinstall @@ -21,5 +21,6 @@ launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist # install printer lpadmin -p PDFwriter -E -v pdfwriter:/ -P /Library/Printers/PPDs/Contents/Resources/RWTS\ PDFwriter.gz -o printer-is-shared=false -# open the Utility -su "$USER" -c "/Library/Printers/RWTS/Utilities/PDFWriter\ Utility.app/Contents/MacOS/PDFWriter\ Utility&" +# open the Utility with correct environment +uid=$(id -u "$USER") +launchctl asuser $uid su "$USER" -c "/Library/Printers/RWTS/Utilities/PDFWriter\ Utility.app/Contents/MacOS/PDFWriter\ Utility"