summaryrefslogtreecommitdiff
path: root/src/caja-main.c
diff options
context:
space:
mode:
authorMonsta <[email protected]>2015-07-13 11:31:48 +0300
committerMonsta <[email protected]>2015-07-13 11:31:48 +0300
commit4b0d231fdf8dfd6d299ec07cc933000a610f0a74 (patch)
treeb736ef67ef48f9d6983c3e8f8ad140a42ff889ae /src/caja-main.c
parent88dc45f1bbe2ecf9d1d3fa6cedf09fa425a202ae (diff)
downloadcaja-4b0d231fdf8dfd6d299ec07cc933000a610f0a74.tar.bz2
caja-4b0d231fdf8dfd6d299ec07cc933000a610f0a74.tar.xz
don't manage desktop and exit with last window when either running
as root or on other desktops thanks to @mtwebster (https://github.com/linuxmint/nemo/commit/acabbaf6ca8e5ffc29851d766339c602777c4427) and @tarakbumba (https://github.com/mate-desktop/caja/pull/409)
Diffstat (limited to 'src/caja-main.c')
-rw-r--r--src/caja-main.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/caja-main.c b/src/caja-main.c
index 4307e0f3..b829bf62 100644
--- a/src/caja-main.c
+++ b/src/caja-main.c
@@ -314,6 +314,20 @@ setup_debug_log (void)
setup_debug_log_glog ();
}
+static gboolean
+running_in_mate (void)
+{
+ return (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "MATE") == 0)
+ || (g_strcmp0 (g_getenv ("XDG_SESSION_DESKTOP"), "MATE") == 0)
+ || (g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "MATE") == 0);
+}
+
+static gboolean
+running_as_root (void)
+{
+ return geteuid () == 0;
+}
+
int
main (int argc, char *argv[])
{
@@ -458,15 +472,16 @@ main (int argc, char *argv[])
setup_debug_log ();
/* If in autostart mode (aka started by mate-session), we need to ensure
- * caja starts with the correct options.
- */
+ * caja starts with the correct options.
+ */
if (autostart_mode)
{
no_default_window = TRUE;
no_desktop = FALSE;
}
- else if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "MATE") != 0)
+ else if (running_as_root () || !running_in_mate ())
{
+ /* do not manage desktop when running as root or on other desktops */
no_desktop = TRUE;
}
@@ -503,8 +518,14 @@ main (int argc, char *argv[])
*/
caja_global_preferences_init ();
- /* exit_with_last_window being FALSE, caja can run without window. */
- exit_with_last_window = g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_EXIT_WITH_LAST_WINDOW);
+ /* exit_with_last_window is already set to TRUE, and we need to keep that value
+ * on other desktops or when running caja as root. Otherwise, we read the value
+ * from the configuration.
+ */
+ if (running_in_mate () && !running_as_root())
+ {
+ exit_with_last_window = g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_EXIT_WITH_LAST_WINDOW);
+ }
application = NULL;