1#!/usr/local/bin/bash
2
3# Script for the 'desktop-manager' subproject of Cairo-Dock
4#
5# Copyright : (C) see the 'copyright' file.
6# E-mail    : see the 'copyright' file.
7#
8#
9# This program is free software; you can redistribute it and/or
10# modify it under the terms of the GNU General Public License
11# as published by the Free Software Foundation; either version 3
12# of the License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18# http://www.gnu.org/licenses/licenses.html#GPL
19
20# This script removes Unity Compiz plugin and launches Cairo-Dock with a short delay
21
22if [ "$1" = "--replace" ]; then
23	UNITY_NAME="unityshell"
24	COMPIZ_FLAT_FILE="$HOME/.config/compiz-1/compizconfig/Default.ini"
25	COMPIZ_GCONF="/apps/compiz-1/general/screen0/options/active_plugins"
26	if test -d "$HOME/.config/compiz-1"; then # compiz >= 0.9
27		# plug-ins in double are NO LONGER filtered by Compiz in this version... (and if plugins are in double or wrong, compiz crashes :) )
28		# flat file
29		if test -f "$COMPIZ_FLAT_FILE"; then
30			pluginsFlat=`grep "s0_active_plugins" $COMPIZ_FLAT_FILE`
31			if test `echo $pluginsFlat | grep -c $UNITY_NAME` -gt 0; then
32				pluginsFlatWithoutUnity=`echo $pluginsFlat | sed -e "s/$UNITY_NAME;//g"`
33				sed -i "/s0_active_plugins/ s/$pluginsFlat/$pluginsFlatWithoutUnity/g" $COMPIZ_FLAT_FILE
34				killall unity-panel-service
35			fi
36		fi
37		# gconf
38		plugins=`gconftool-2 -g $COMPIZ_GCONF`
39		if test `echo $plugins | grep -c $UNITY_NAME` -gt 0; then
40			pluginsWithoutUnity=`echo $plugins | sed -e "s/$UNITY_NAME,//g"`
41			gconftool-2 -s $COMPIZ_GCONF --type=list --list-type=string "$pluginsWithoutUnity"
42			killall unity-panel-service
43		fi
44	fi
45fi
46
47if test `ps -U $USER -u $USER u | grep -c " [c]airo-dock"` -eq 0; then # cairo-dock not launched
48	cairo-dock -w 3
49fi
50