blob: 48e9e74aeef697fe8e243fdc5e305238af5b1333 [file] [log] [blame]
Stepan Salenikovich0d707a62015-05-29 10:48:04 -04001#!/bin/bash
Stepan Salenikovichee805ad2015-06-03 10:43:51 -04002#
Stepan Salenikovichbe87d2c2016-01-25 14:14:34 -05003# Copyright (C) 2015-2016 Savoir-faire Linux Inc.
Stepan Salenikovichee805ad2015-06-03 10:43:51 -04004# 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#
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040021
22HAS_KDE=0
23HAS_GNOME=0
24
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040025if type "ring-kde" > /dev/null 2> /dev/null; then
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040026 HAS_KDE=1
27fi
28
Stepan Salenikovich526c41e2016-06-08 16:48:20 -040029if type "gnome-ring" > /dev/null 2> /dev/null; then
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040030 HAS_GNOME=1
31fi
32
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040033# No clients installd
34if [ $HAS_KDE == "0" ] && [ $HAS_GNOME == "0" ]; then
35 echo "Ring not found" >&2
36 exit 1
37fi
38
39# Only one client is installed
40if [ $HAS_KDE == "1" ] && [ $HAS_GNOME == "0" ]; then
41 ring-kde $*
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040042 exit $?
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040043elif [ $HAS_KDE == "0" ] && [ $HAS_GNOME == "1" ]; then
Stepan Salenikovich526c41e2016-06-08 16:48:20 -040044 gnome-ring $*
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040045 exit $?
46fi
47
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040048# Both clients installed: run KDE client if KDE wm is running
49# else use the Gnome client.
50if [ -z "$(ps aux | grep kwin | grep -v grep)" ]; then
Stepan Salenikovich526c41e2016-06-08 16:48:20 -040051 gnome-ring $*
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040052 exit $?
53else
Stepan Salenikovichee805ad2015-06-03 10:43:51 -040054 ring-kde $*
Stepan Salenikovich0d707a62015-05-29 10:48:04 -040055 exit $?
56fi