1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
/*---------------------------------------------------------------------------------
Name : check_desktop.c
Author : Marvin Raaijmakers
Description : Identifies the currently running desktop environment
Date of last change: 24-Sep-2006
History : 24-Sep-2006 is_gnome_desktop() now also returns TRUE when
the application "gnome-panel" is running.
03-Jun-2006 is_gnome_desktop() now checks if the
GNOME_DESKTOP_SESSION_ID env variable exists
26-Jan-2006 Changed "dcop kdesktop >> /dev/null" to
"dcop kdesktop &> /dev/null"
Copyright (C) 2004-2006 Marvin Raaijmakers
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
You can contact me at: marvinr(at)users(dot)sf(dot)net
(replace (at) by @ and (dot) by .)
-----------------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <wait.h>
#include <check_desktop.h>
static char is_kde_desktop(void);
static char is_gnome_desktop(void);
char
is_kde_desktop (void)
/*
input:
-
output:
-
returns:
TRUE if KDE is running, otherwise FALSE
description:
This function checks if KDE is running.
*/
{
if ( WEXITSTATUS(system("dcop kdesktop &> /dev/null")) ) /* If KDE is NOT running */
{
return (FALSE);
}
return (TRUE);
}
char
is_gnome_desktop (void)
/*
input:
-
output:
-
returns:
TRUE if GNOME is running, otherwise FALSE
description:
This function checks if GNOME is running.
*/
{
return (getenv("GNOME_DESKTOP_SESSION_ID") != NULL || !WEXITSTATUS( system("ps -C \"gnome-panel\" &> /dev/null") ));
}
DESKTOP
check_desktop (void)
/*
input:
-
output:
-
returns:
The currently running desktop environment or UNKNOWN_DESKTOP is no recognized
DE is running
description:
This function finds out which desktop environment is running.
*/
{
if (is_kde_desktop())
{
return (KDE);
}
else if (is_gnome_desktop())
{
return (GNOME);
}
else
{
return (UNKNOWN_DESKTOP);
}
}
|