From 91dcb951c19e7a05b16f81474e0708e2389ce1d3 Mon Sep 17 00:00:00 2001
From: tangjie02 <tangjie02@kylinos.com.cn>
Date: Mon, 9 Aug 2021 18:00:34 +0800
Subject: [PATCH 2/3] feature(kiran): Support kiran desktop environment.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 支持kiran桌面环境

Signed-off-by: tangjie02 <tangjie02@kylinos.com.cn>
---
 libegg/eggsmclient.c   | 10 +++++++++-
 src/caja-application.c | 11 +++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/libegg/eggsmclient.c b/libegg/eggsmclient.c
index c404349..3113e6b 100644
--- a/libegg/eggsmclient.c
+++ b/libegg/eggsmclient.c
@@ -59,6 +59,14 @@ running_in_mate (void)
         || (g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "mate") == 0);
 }
 
+static gboolean
+running_in_kiran (void)
+{
+    return (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "KIRAN") == 0)
+        || (g_strcmp0 (g_getenv ("XDG_SESSION_DESKTOP"), "kiran") == 0)
+        || (g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "kiran") == 0);
+}
+
 static void
 egg_sm_client_init (EggSMClient *client)
 {
@@ -360,7 +368,7 @@ egg_sm_client_get (void)
           as egg_sm_client_set_mode must be called prior to start of main loop
           to stop caja restart but this is diffcult in GtkApplication */
 
-		if (geteuid () == 0 || !running_in_mate ()){
+		if (geteuid () == 0 || !(running_in_mate () || running_in_kiran ())){
         global_client = g_object_new (EGG_TYPE_SM_CLIENT, NULL);
         }
     }
diff --git a/src/caja-application.c b/src/caja-application.c
index 2791bd9..8d33baa 100644
--- a/src/caja-application.c
+++ b/src/caja-application.c
@@ -1838,6 +1838,13 @@ running_in_mate (void)
         || (g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "mate") == 0);
 }
 
+static gboolean
+running_in_kiran (void)
+{
+    return (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "KIRAN") == 0)
+        || (g_strcmp0 (g_getenv ("XDG_SESSION_DESKTOP"), "KIRAN") == 0)
+        || (g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "KIRAN") == 0);
+}
 static gboolean
 running_as_root (void)
 {
@@ -2110,7 +2117,7 @@ init_desktop (CajaApplication *self)
         self->priv->no_desktop = TRUE;
     }
 
-    if (!running_in_mate ())
+    if (!running_in_mate () && !running_in_kiran ())
 	{
         /* do not manage desktop when running as root or on other desktops unless forced */
         self->priv->no_desktop = TRUE;
@@ -2262,7 +2269,7 @@ caja_application_startup (GApplication *app)
      * Otherwise, we read the value from the configuration.
      */
 
-    if (running_in_mate () && !running_as_root())
+    if ((running_in_mate () || running_in_kiran ()) && !running_as_root())
     {
         GApplication *instance;
 
-- 
2.33.0

