From 4b0d231fdf8dfd6d299ec07cc933000a610f0a74 Mon Sep 17 00:00:00 2001 From: Monsta Date: Mon, 13 Jul 2015 11:31:48 +0300 Subject: 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) --- src/caja-main.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src') 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; -- cgit v1.2.1