Prevent repeated checks for the desktop environment.
It is sufficient to check the desktop environment only once. Also don't shadow 'stdin', 'stdout' and 'stderr'.
This commit is contained in:
parent
39dedae0d1
commit
cd8b1e5b22
1 changed files with 17 additions and 10 deletions
27
src/sokoke.c
27
src/sokoke.c
|
@ -103,21 +103,28 @@ void sokoke_widget_popup(GtkWidget* widget, GtkMenu* menu
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SOKOKE_DESKTOP_UNKNOWN,
|
SOKOKE_DESKTOP_UNTESTED,
|
||||||
SOKOKE_DESKTOP_XFCE
|
SOKOKE_DESKTOP_XFCE,
|
||||||
|
SOKOKE_DESKTOP_UNKNOWN
|
||||||
} SokokeDesktop;
|
} SokokeDesktop;
|
||||||
|
|
||||||
static SokokeDesktop sokoke_get_desktop(void)
|
static SokokeDesktop sokoke_get_desktop(void)
|
||||||
{
|
{
|
||||||
// Are we running in Xfce?
|
static SokokeDesktop desktop = SOKOKE_DESKTOP_UNTESTED;
|
||||||
gint result; gchar* stdout; gchar* stderr;
|
if(G_UNLIKELY(desktop == SOKOKE_DESKTOP_UNTESTED))
|
||||||
gboolean success = g_spawn_command_line_sync(
|
{
|
||||||
"xprop -root _DT_SAVE_MODE | grep -q xfce4"
|
// Are we running in Xfce?
|
||||||
, &stdout, &stderr, &result, NULL);
|
gint result; gchar* out; gchar* err;
|
||||||
if(success && !result)
|
gboolean success = g_spawn_command_line_sync(
|
||||||
return SOKOKE_DESKTOP_XFCE;
|
"xprop -root _DT_SAVE_MODE | grep -q xfce4"
|
||||||
|
, &out, &err, &result, NULL);
|
||||||
|
if(success && !result)
|
||||||
|
desktop = SOKOKE_DESKTOP_XFCE;
|
||||||
|
else
|
||||||
|
desktop = SOKOKE_DESKTOP_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
return SOKOKE_DESKTOP_UNKNOWN;
|
return desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpointer sokoke_xfce_header_new(const gchar* icon, const gchar* title)
|
gpointer sokoke_xfce_header_new(const gchar* icon, const gchar* title)
|
||||||
|
|
Loading…
Reference in a new issue