summaryrefslogtreecommitdiff
path: root/compiz-decorator
blob: 84a0c461ad2cf6ce6ef52edb927e8aa94979f5dc (plain)
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
#!/bin/sh
# Starts Compiz Decorator depending on the DE
# 
# Copyright (c) 2007 CyberOrg <cyberorg@cyberorg.info>
# Based on compiz-manager script by Kristian LyngstĂžl <kristian@bohemians.org>
# 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
# (at your option) 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 St, Fifth Floor, Boston, MA  02110-1301  USA
#
# Contributions by: crdlb
#
COMPIZ_BIN_PATH=/usr/bin/
KWIN=`which kwin`
METACITY="/usr/bin/metacity"

#
# Default to gtk/kde(4)-window-decorator
#
USE_EMERALD="no"
DECORATOR=""

#Do not leave users without decoration if decorator fails
if [ "$DESKTOP_SESSION" == "kde" ]; then
    FALLBACKWM="${KWIN}"
else
    FALLBACKWM="${METACITY}"
fi
FALLBACKWM_OPTIONS=" --replace"

#
# Set to yes to enable verbose
#
VERBOSE="yes"
 
#
# Echos the arguments if verbose
#
verbose()
{
    if [ "x$VERBOSE" = "xyes" ]; then
        printf "$*"
    fi
}

# Read configuration from XDG paths
if [ -z "$XDG_CONFIG_DIRS" ]; then
    test -f /etc/xdg/compiz/compiz-manager && . /etc/xdg/compiz/compiz-manager
else
    test -f $XDG_CONFIG_DIRS/compiz/compiz-manager && . $XDG_CONFIG_DIRS/compiz/compiz-manager
fi

if [ -z "$XDG_CONFIG_HOME" ]; then
    test -f $HOME/.config/compiz/compiz-manager && . $HOME/.config/compiz/compiz-manager
else
    test -f $XDG_CONFIG_HOME/compiz/compiz-manager && .  $XDG_CONFIG_HOME/compiz/compiz-manager
fi

# start a decorator
if [ -x ${COMPIZ_BIN_PATH}emerald ] && [ "$USE_EMERALD" = "yes" ]; then
    DECORATOR=emerald
elif [ -x ${COMPIZ_BIN_PATH}gtk-window-decorator ] && [ -n "$GNOME_DESKTOP_SESSION_ID" ]; then
    DECORATOR=gtk-window-decorator
elif [ -x ${COMPIZ_BIN_PATH}kde-window-decorator ] && [ -n "$KDE_FULL_SESSION" ]; then
    DECORATOR=kde-window-decorator
elif [ -x ${COMPIZ_BIN_PATH}kde4-window-decorator ] && [ x$KDE_SESSION_VERSION = x"4" ]; then
    DECORATOR=kde4-window-decorator
fi

# fall back to any decorator that is installed
if [ -z "$DECORATOR" ]; then
    verbose "Couldn't find a perfect decorator match; trying all decorators\n"
    if [ -x ${COMPIZ_BIN_PATH}emerald ]; then
        DECORATOR=emerald
    elif [ -x ${COMPIZ_BIN_PATH}gtk-window-decorator ]; then
	DECORATOR=gtk-window-decorator
    elif [ -x ${COMPIZ_BIN_PATH}kde-window-decorator ]; then
	DECORATOR=kde-window-decorator
    elif [ -x ${COMPIZ_BIN_PATH}kde4-window-decorator ]; then
	DECORATOR=kde4-window-decorator
    fi
fi

if [ -n "$DECORATOR" ]; then
    verbose "Starting ${DECORATOR}\n"
    ${COMPIZ_BIN_PATH}$DECORATOR "$@"
else
    verbose "Found no decorator to start\n"
    exec $FALLBACKWM $FALLBACKWM_OPTIONS
fi