Skip to content

Commit e010574

Browse files
authored
feat(macos): add background-app configuration to support LSUIElement in Info.plist (#318)
1 parent e3dcd3e commit e010574

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

.changes/macos-background-app.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cargo-packager": patch
3+
"@crabnebula/packager": patch
4+
---
5+
6+
Add `background-app` config setting for macOS to set `LSUIElement` to `true`.

bindings/packager/nodejs/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,11 @@
783783
"items": {
784784
"type": "string"
785785
}
786+
},
787+
"backgroundApp": {
788+
"description": "Whether this is a background application. If true, the app will not appear in the Dock.\n\nSets the `LSUIElement` flag in the macOS plist file.",
789+
"default": false,
790+
"type": "boolean"
786791
}
787792
},
788793
"additionalProperties": false

bindings/packager/nodejs/src-ts/config.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ export interface MacOsConfig {
437437
* Apps that need to be packaged within the app.
438438
*/
439439
embeddedApps?: string[] | null;
440+
/**
441+
* Whether this is a background application. If true, the app will not appear in the Dock.
442+
*
443+
* Sets the `LSUIElement` flag in the macOS plist file.
444+
*/
445+
backgroundApp?: boolean;
440446
}
441447
/**
442448
* The Linux Debian configuration.

crates/packager/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,11 @@
783783
"items": {
784784
"type": "string"
785785
}
786+
},
787+
"backgroundApp": {
788+
"description": "Whether this is a background application. If true, the app will not appear in the Dock.\n\nSets the `LSUIElement` flag in the macOS plist file.",
789+
"default": false,
790+
"type": "boolean"
786791
}
787792
},
788793
"additionalProperties": false

crates/packager/src/config/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,11 @@ pub struct MacOsConfig {
745745
/// Apps that need to be packaged within the app.
746746
#[serde(alias = "embedded-apps", alias = "embedded_apps")]
747747
pub embedded_apps: Option<Vec<String>>,
748+
/// Whether this is a background application. If true, the app will not appear in the Dock.
749+
///
750+
/// Sets the `LSUIElement` flag in the macOS plist file.
751+
#[serde(default, alias = "background_app", alias = "background-app")]
752+
pub background_app: bool,
748753
}
749754

750755
impl MacOsConfig {

crates/packager/src/package/app/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,13 @@ fn create_info_plist(
317317

318318
plist.insert("LSRequiresCarbon".into(), true.into());
319319
plist.insert("NSHighResolutionCapable".into(), true.into());
320+
321+
if let Some(macos_config) = config.macos() {
322+
if macos_config.background_app {
323+
plist.insert("LSUIElement".into(), true.into());
324+
}
325+
}
326+
320327
if let Some(copyright) = &config.copyright {
321328
plist.insert("NSHumanReadableCopyright".into(), copyright.clone().into());
322329
}

0 commit comments

Comments
 (0)