aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-03-21 09:27:45 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-03-21 10:21:28 +0100
commit6a0b2ef766fc208b36cc1f8f6a4c99e354c161e5 (patch)
treeb7f1f62d77a55acd6202664f652df4d8ebf3606b
parenteb297fbbdc4befba9b187183ad20311040ab71a3 (diff)
downloadayatana-indicator-session-6a0b2ef766fc208b36cc1f8f6a4c99e354c161e5.tar.gz
ayatana-indicator-session-6a0b2ef766fc208b36cc1f8f6a4c99e354c161e5.tar.bz2
ayatana-indicator-session-6a0b2ef766fc208b36cc1f8f6a4c99e354c161e5.zip
Add XFCE Support.
* Check if XDG_CURRENT_DESKTOP is set to XFCE. * Use xfce4-session-logout as logout/reboot/shutdown prompt. * Use xfce4-settings-manager for 'Settings...'. * Use xflock4 to attept a session lock. * Use xfce4-about for info about this computer (not fully appropriate but XFCE does not have any appropriate equivalent as found in GNOME or MATE). Fixes AyatanaIndicators/ayatana-indicator-session#1.
-rw-r--r--src/backend-dbus/actions.c65
-rw-r--r--src/utils.c21
-rw-r--r--src/utils.h1
3 files changed, 78 insertions, 9 deletions
diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c
index 84d6600..a8699de 100644
--- a/src/backend-dbus/actions.c
+++ b/src/backend-dbus/actions.c
@@ -94,6 +94,7 @@ typedef enum
PROMPT_WITH_ZENITY,
PROMPT_WITH_AYATANA,
PROMPT_WITH_MATE,
+ PROMPT_WITH_XFCE,
}
prompt_status_t;
@@ -111,6 +112,19 @@ have_mate_program (const gchar *program)
return FALSE;
}
+static gboolean
+have_xfce_program (const gchar *program)
+{
+ g_auto(GStrv) desktop_names = NULL;
+
+ if (is_xfce()) {
+ g_autofree gchar *path = g_find_program_in_path (program);
+ return path != NULL;
+ }
+
+ return FALSE;
+}
+
static prompt_status_t
get_prompt_status (IndicatorSessionActionsDbus * self)
{
@@ -123,6 +137,10 @@ get_prompt_status (IndicatorSessionActionsDbus * self)
if ((prompt == PROMPT_NONE) && have_mate_program ("mate-session-save"))
prompt = PROMPT_WITH_MATE;
+ /* can we use the XFCE prompt? */
+ if ((prompt == PROMPT_NONE) && have_xfce_program ("xfce4-session-logout"))
+ prompt = PROMPT_WITH_XFCE;
+
/* can we use the Unity/Ayatana prompt? */
if ((prompt == PROMPT_NONE) && p && p->end_session_dialog)
{
@@ -809,6 +827,10 @@ my_logout (IndicatorSessionActions * actions)
run_outside_app ("mate-session-save --logout-dialog");
break;
+ case PROMPT_WITH_XFCE:
+ run_outside_app ("xfce4-session-logout");
+ break;
+
case PROMPT_NONE:
logout_now (self);
break;
@@ -851,6 +873,10 @@ my_reboot (IndicatorSessionActions * actions)
run_outside_app ("mate-session-save --shutdown-dialog");
break;
+ case PROMPT_WITH_XFCE:
+ run_outside_app ("xfce4-session-logout");
+ break;
+
case PROMPT_NONE:
reboot_now (self);
break;
@@ -888,6 +914,10 @@ my_power_off (IndicatorSessionActions * actions)
run_outside_app ("mate-session-save --shutdown-dialog");
break;
+ case PROMPT_WITH_XFCE:
+ run_outside_app ("xfce4-session-logout");
+ break;
+
case PROMPT_WITH_ZENITY:
if (zenity_question (self,
"system-shutdown",
@@ -908,15 +938,6 @@ my_power_off (IndicatorSessionActions * actions)
****
***/
-static void
-my_desktop_help (IndicatorSessionActions * self G_GNUC_UNUSED)
-{
- if (have_mate_program ("yelp"))
- run_outside_app ("yelp help:mate-user-guide");
- else
- run_outside_app ("yelp");
-}
-
static char *
find_browser ()
{
@@ -949,6 +970,24 @@ find_browser ()
}
static void
+my_desktop_help (IndicatorSessionActions * self G_GNUC_UNUSED)
+{
+ static char * browser = NULL;
+
+ if (have_mate_program ("yelp"))
+ run_outside_app ("yelp help:mate-user-guide");
+ else if (is_xfce())
+ {
+ if (browser == NULL)
+ browser = find_browser();
+ if (browser != NULL)
+ run_outside_app(g_strdup_printf("%s '%s'", browser, "https://docs.xfce.org/"));
+ }
+ else
+ run_outside_app ("yelp");
+}
+
+static void
my_distro_help (IndicatorSessionActions * self G_GNUC_UNUSED)
{
static char * browser = NULL;
@@ -1002,6 +1041,8 @@ my_settings (IndicatorSessionActions * self G_GNUC_UNUSED)
run_outside_app ("gnome-control-center");
else if (have_mate_program ("mate-control-center"))
run_outside_app ("mate-control-center");
+ else if (have_xfce_program ("xfce4-settings-manager"))
+ run_outside_app ("xfce4-settings-manager");
else
zenity_warning ("dialog-warning",
_("Warning"),
@@ -1030,6 +1071,8 @@ my_about (IndicatorSessionActions * self G_GNUC_UNUSED)
run_outside_app ("gnome-control-center info");
else if (have_mate_program ("mate-system-monitor"))
run_outside_app ("mate-system-monitor --show-system-tab");
+ else if (have_xfce_program ("xfce4-about"))
+ run_outside_app ("xfce4-about");
else
zenity_warning ("dialog-warning",
_("Warning"),
@@ -1060,6 +1103,10 @@ lock_current_session (IndicatorSessionActions * self, gboolean immediate)
{
run_outside_app ("mate-screensaver-command --lock");
}
+ else if (have_xfce_program ("xflock4"))
+ {
+ run_outside_app ("xflock4");
+ }
else
{
g_return_if_fail (p->screen_saver != NULL);
diff --git a/src/utils.c b/src/utils.c
index 4bc6d68..dad9354 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -79,6 +79,27 @@ is_mate ()
return FALSE;
}
+gboolean
+is_xfce ()
+{
+ const gchar *xdg_current_desktop;
+ gchar **desktop_names;
+ int i;
+
+ xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
+ if (xdg_current_desktop != NULL) {
+ desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
+ for (i = 0; desktop_names[i]; ++i) {
+ if (!g_strcmp0 (desktop_names[i], "XFCE")) {
+ g_strfreev (desktop_names);
+ return TRUE;
+ }
+ }
+ g_strfreev (desktop_names);
+ }
+ return FALSE;
+}
+
GHashTable*
get_os_release (void)
{
diff --git a/src/utils.h b/src/utils.h
index bb9e750..69bf2c6 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -23,6 +23,7 @@
gboolean is_unity();
gboolean is_gnome();
gboolean is_mate();
+gboolean is_xfce();
const char* get_distro_name();
const char* get_distro_url();