Browse Source

feat(core): make setting of gtk app id optional (#10397)

* feat(core): make setting of gtk app id optional

* Fix change file

* Update .changes/linux-option-gtk-app-id.md

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>

* [skip ci] Update linux-option-gtk-app-id.md

* Update app.rs

* Update app.rs

---------

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Vladimir Stoilov 1 year ago
parent
commit
7aeac39e7f

+ 6 - 0
.changes/linux-option-gtk-app-id.md

@@ -0,0 +1,6 @@
+---
+"tauri-utils": "patch:enhance"
+"tauri": "patch:enhance"
+---
+
+Make the set of gtk application id optional, to allow more then one instance of the app running at the same time.

+ 6 - 0
core/tauri-config-schema/schema.json

@@ -34,6 +34,7 @@
     "app": {
       "description": "The App configuration.",
       "default": {
+        "enableGTKAppId": false,
         "macOSPrivateApi": false,
         "security": {
           "assetProtocol": {
@@ -195,6 +196,11 @@
           "description": "Whether we should inject the Tauri API on `window.__TAURI__` or not.",
           "default": false,
           "type": "boolean"
+        },
+        "enableGTKAppId": {
+          "description": "If set to true \"identifier\" will be set as GTK app ID (on systems that use GTK).",
+          "default": false,
+          "type": "boolean"
         }
       },
       "additionalProperties": false

+ 7 - 1
core/tauri-utils/src/config.rs

@@ -1803,6 +1803,9 @@ pub struct AppConfig {
   /// Whether we should inject the Tauri API on `window.__TAURI__` or not.
   #[serde(default, alias = "with-global-tauri")]
   pub with_global_tauri: bool,
+  /// If set to true "identifier" will be set as GTK app ID (on systems that use GTK).
+  #[serde(rename = "enableGTKAppId", alias = "enable-gtk-app-id", default)]
+  pub enable_gtk_app_id: bool,
 }
 
 impl AppConfig {
@@ -2732,6 +2735,7 @@ mod build {
       let tray_icon = opt_lit(self.tray_icon.as_ref());
       let macos_private_api = self.macos_private_api;
       let with_global_tauri = self.with_global_tauri;
+      let enable_gtk_app_id = self.enable_gtk_app_id;
 
       literal_struct!(
         tokens,
@@ -2740,7 +2744,8 @@ mod build {
         security,
         tray_icon,
         macos_private_api,
-        with_global_tauri
+        with_global_tauri,
+        enable_gtk_app_id
       );
     }
   }
@@ -2817,6 +2822,7 @@ mod test {
       tray_icon: None,
       macos_private_api: false,
       with_global_tauri: false,
+      enable_gtk_app_id: false,
     };
 
     // create a build config

+ 7 - 1
core/tauri/src/app.rs

@@ -1706,6 +1706,12 @@ tauri::Builder::default()
       self.invoke_key,
     ));
 
+    let app_id = if manager.config.app.enable_gtk_app_id {
+      Some(manager.config.identifier.clone())
+    } else {
+      None
+    };
+
     let runtime_args = RuntimeInitArgs {
       #[cfg(any(
         target_os = "linux",
@@ -1714,7 +1720,7 @@ tauri::Builder::default()
         target_os = "netbsd",
         target_os = "openbsd"
       ))]
-      app_id: Some(manager.config.identifier.clone()),
+      app_id,
 
       #[cfg(windows)]
       msg_hook: {

+ 1 - 0
core/tauri/src/test/mod.rs

@@ -113,6 +113,7 @@ pub fn mock_context<R: Runtime, A: Assets<R>>(assets: A) -> crate::Context<R> {
         security: Default::default(),
         tray_icon: None,
         macos_private_api: false,
+        enable_gtk_app_id: false,
       },
       bundle: Default::default(),
       build: Default::default(),

+ 6 - 0
tooling/cli/schema.json

@@ -34,6 +34,7 @@
     "app": {
       "description": "The App configuration.",
       "default": {
+        "enableGTKAppId": false,
         "macOSPrivateApi": false,
         "security": {
           "assetProtocol": {
@@ -195,6 +196,11 @@
           "description": "Whether we should inject the Tauri API on `window.__TAURI__` or not.",
           "default": false,
           "type": "boolean"
+        },
+        "enableGTKAppId": {
+          "description": "If set to true \"identifier\" will be set as GTK app ID (on systems that use GTK).",
+          "default": false,
+          "type": "boolean"
         }
       },
       "additionalProperties": false