blob: c158f684839685c12eb366dad54f60180eccd56c [file] [log] [blame]
Stepan Salenikovich0d707a62015-05-29 10:48:04 -04001#!/bin/bash
Stepan Salenikovichee805ad2015-06-03 10:43:51 -04002#
3# Copyright (C) 2015 Savoir-Faire Linux Inc.
4# Author: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com>
5# Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (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#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20#
21# Additional permission under GNU GPL version 3 section 7:
22#
23# If you modify this program, or any covered work, by linking or
24# combining it with the OpenSSL project's OpenSSL library (or a
25# modified version of that library), containing parts covered by the
26# terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
27# grants you additional permission to convey the resulting work.
28# Corresponding Source for a non-source form of such a combination
29# shall include the source code for the parts of OpenSSL used as well
30# as that of the covered work.
31#
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040032
33HAS_KDE=0
34HAS_GNOME=0
35
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040036if type "ring-kde" > /dev/null 2> /dev/null; then
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040037 HAS_KDE=1
38fi
39
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040040if type "gnome-ring" > /dev/null 2> /dev/null; then
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040041 HAS_GNOME=1
42fi
43
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040044# No clients installd
45if [ $HAS_KDE == "0" ] && [ $HAS_GNOME == "0" ]; then
46 echo "Ring not found" >&2
47 exit 1
48fi
49
50# Only one client is installed
51if [ $HAS_KDE == "1" ] && [ $HAS_GNOME == "0" ]; then
52 ring-kde $*
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040053 exit $?
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040054elif [ $HAS_KDE == "0" ] && [ $HAS_GNOME == "1" ]; then
55 gnome-ring $*
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040056 exit $?
57fi
58
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040059# Both clients installed: run KDE client if KDE wm is running
60# else use the Gnome client.
61if [ -z "$(ps aux | grep kwin | grep -v grep)" ]; then
62 gnome-ring $*
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040063 exit $?
64else
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040065 ring-kde $*
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040066 exit $?
67fi