macos: set env var for app bundle to detect app launch vs CLI

This commit is contained in:
Mitchell Hashimoto
2023-09-20 11:10:46 -07:00
parent 423e55ce0f
commit cdbf16e13b
4 changed files with 22 additions and 2 deletions

View File

@@ -2,7 +2,6 @@ import AppKit
import OSLog
import GhosttyKit
@NSApplicationMain
class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyAppStateDelegate {
// The application logger. We should probably move this at some point to a dedicated
// class/struct but for now it lives here! 🤷

12
macos/Sources/main.swift Normal file
View File

@@ -0,0 +1,12 @@
import AppKit
import Cocoa
// We put the GHOSTTY_MAC_APP env var into the Info.plist to detect
// whether we launch from the app or not. A user can fake this if
// they want but they're doing so at their own detriment...
let process = ProcessInfo.processInfo
if (process.environment["GHOSTTY_MAC_APP"] == "") {
AppDelegate.logger.warning("NOT IN THE MAC APP")
}
_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)