Skip to content

Commit

Permalink
Add keepOpen config, closes #73
Browse files Browse the repository at this point in the history
  • Loading branch information
kofigumbs committed Mar 6, 2023
1 parent 37ef174 commit 2af315d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions Multi.app/Contents/Resources/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ <h1 style="margin: 0; padding: 0; font-weight:200;">Configure your <b>Multi</b>
}, tab.customCookies);
});
validate(undefinedOr(boolean, config.windowed), `an OPTIONAL BOOLEAN at "windowed" field`);
validate(undefinedOr(boolean, config.keepOpenAfterWindowClosed), `an OPTIONAL BOOLEAN at "keepOpenAfterWindowClosed" field`);
validate(undefinedOr(boolean, config.alwaysNotify), `an OPTIONAL BOOLEAN at "alwaysNotify" field`);
validate(undefinedOr(boolean, config.alwaysOnTop), `an OPTIONAL BOOLEAN at "alwaysOnTop" field`);
validate(undefinedOr(string, config.openNewWindowsWith), `an OPTIONAL STRING at "openNewWindowsWith" field`);
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The JSON configuration uses the following top-level fields:
|------------------------------|---------------------------------------------------|----------------------------------------------------------------------|
| `tabs` | Array (Required) | Titles and URLs of tabs for this app |
| `windowed` | Boolean (Optional, default `false`) | Start the app with each tab in its own window |
| `keepOpenAfterWindowClosed` | Boolean (Optional, default `false`) | Prevents app from quitting when the last window is closed |
| `alwaysNotify` | Boolean (Optional, default `false`) | Show macOS notifications even if your app is currently focused |
| `alwaysOnTop` | Boolean (Optional, default `false`) | Position this app's window on top of all others |
| `openNewWindowsWith` | String (Optional, macOS 10.15+) | Override system default browser for external links — value is a _bundle identifier_ like `com.apple.Safari`, `com.google.Chrome`, or `com.mozilla.firefox` |
Expand Down Expand Up @@ -112,6 +113,7 @@ Here's a fancier example that uses the optional fields referenced above:
}
],
"windowed": true,
"keepOpenAfterWindowClosed": true,
"alwaysNotify": true,
"alwaysOnTop": true,
"openNewWindowsWith": "com.apple.Safari",
Expand Down
2 changes: 1 addition & 1 deletion Sources/Runtime/Browser+NSApplicationDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ extension Browser: NSApplicationDelegate {
}

public func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
return !Config.keepOpenAfterWindowClosed
}
}
5 changes: 5 additions & 0 deletions Sources/Runtime/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AppKit
struct Config {
struct Schema: Decodable {
let windowed: Bool?
let keepOpenAfterWindowClosed: Bool?
let alwaysNotify: Bool?
let alwaysOnTop: Bool?
let openNewWindowsWith: String?
Expand Down Expand Up @@ -41,6 +42,10 @@ struct Config {
return schema?.windowed ?? false
}()

static let keepOpenAfterWindowClosed: Bool = {
return schema?.keepOpenAfterWindowClosed ?? false
}()

static let alwaysNotify: Bool = {
return schema?.alwaysNotify ?? false
}()
Expand Down

0 comments on commit 2af315d

Please sign in to comment.