| 1 |
/** |
| 2 |
* This file is a part of the Cairo-Dock project |
| 3 |
* |
| 4 |
* Copyright : (C) see the 'copyright' file. |
| 5 |
* E-mail : see the 'copyright' file. |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or |
| 8 |
* modify it under the terms of the GNU General Public License |
| 9 |
* as published by the Free Software Foundation; either version 3 |
| 10 |
* of the License, or (at your option) any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details. |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <stdlib.h> |
| 21 |
#include <cairo-dock.h> |
| 22 |
|
| 23 |
#include "applet-utils.h" |
| 24 |
|
| 25 |
|
| 26 |
void env_backend_logout (void) |
| 27 |
{ |
| 28 |
// since Gnome 3, gnome-session-save has been replaced by gnome-session-quit |
| 29 |
gchar *cResult = cairo_dock_launch_command_sync ("which gnome-session-quit"); |
| 30 |
if (cResult != NULL && *cResult == '/') |
| 31 |
cairo_dock_launch_command ("gnome-session-quit --logout"); |
| 32 |
else |
| 33 |
{ |
| 34 |
g_free (cResult); |
| 35 |
// Cinnamon? |
| 36 |
cResult = cairo_dock_launch_command_sync ("which cinnamon-session-quit"); |
| 37 |
if (cResult != NULL && *cResult == '/') |
| 38 |
cairo_dock_launch_command ("cinnamon-session-quit --logout"); |
| 39 |
else |
| 40 |
cairo_dock_launch_command ("gnome-session-save --kill --gui"); |
| 41 |
} |
| 42 |
g_free (cResult); |
| 43 |
} |
| 44 |
|
| 45 |
void env_backend_shutdown (void) |
| 46 |
{ |
| 47 |
// since Gnome 3, gnome-session-save has been replaced by gnome-session-quit |
| 48 |
gchar *cResult = cairo_dock_launch_command_sync ("which gnome-session-quit"); |
| 49 |
if (cResult != NULL && *cResult == '/') |
| 50 |
cairo_dock_launch_command ("gnome-session-quit --power-off"); |
| 51 |
else |
| 52 |
{ |
| 53 |
g_free (cResult); |
| 54 |
// Cinnamon? |
| 55 |
cResult = cairo_dock_launch_command_sync ("which cinnamon-session-quit"); |
| 56 |
if (cResult != NULL && *cResult == '/') |
| 57 |
cairo_dock_launch_command ("cinnamon-session-quit --power-off"); |
| 58 |
else |
| 59 |
cairo_dock_launch_command ("gnome-session-save --shutdown-dialog"); |
| 60 |
} |
| 61 |
g_free (cResult); |
| 62 |
} |
| 63 |
|
| 64 |
void env_backend_lock_screen (void) |
| 65 |
{ |
| 66 |
cairo_dock_launch_command (MY_APPLET_SHARE_DATA_DIR"/../shared-files/scripts/lock-screen.sh"); |
| 67 |
} |
| 68 |
|
| 69 |
void env_backend_setup_time (void) |
| 70 |
{ |
| 71 |
static gboolean bChecked = FALSE; |
| 72 |
static const gchar *cCmd = NULL; |
| 73 |
if (!bChecked) |
| 74 |
{ |
| 75 |
bChecked = TRUE; |
| 76 |
gchar *cResult = cairo_dock_launch_command_sync ("which gnome-control-center"); // Gnome3 |
| 77 |
if (cResult != NULL && *cResult == '/') |
| 78 |
{ |
| 79 |
cCmd = "gnome-control-center datetime"; |
| 80 |
} |
| 81 |
else |
| 82 |
{ |
| 83 |
g_free (cResult); |
| 84 |
cResult = cairo_dock_launch_command_sync ("which time-admin"); // Gnome2 |
| 85 |
if (cResult != NULL && *cResult == '/') |
| 86 |
cCmd = "time-admin"; // it uses PolicyKit => no gksudo. |
| 87 |
} |
| 88 |
g_free (cResult); |
| 89 |
} |
| 90 |
if (cCmd) |
| 91 |
cairo_dock_launch_command (cCmd); |
| 92 |
else |
| 93 |
cd_warning ("couldn't guess what program to use to setup the time and date."); |
| 94 |
} |
| 95 |
|
| 96 |
void env_backend_show_system_monitor (void) |
| 97 |
{ |
| 98 |
cairo_dock_launch_command ("gnome-system-monitor"); |
| 99 |
} |