2011-06-19 01:32:55 +02:00
#!/bin/bash
2011-09-17 16:05:38 +02:00
# Script for the Help applet of Cairo-Dock
#
# Copyright : (C) see the 'copyright' file.
# E-mail : see the 'copyright' file.
#
#
# 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 3
# 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.
# http://www.gnu.org/licenses/licenses.html#GPL
2011-07-16 23:05:45 +02:00
# Note: we have to use $HOME instead of '~'
2011-06-19 01:32:55 +02:00
# Enable dbus, scale and expo plug-ins in Compiz.
if test -n "`which compiz`" ; then
2012-04-07 02:41:39 +02:00
if test -n "`which gconftool-2`" ; then
GCONFTOOL_CHECK = 1
fi
2014-08-17 20:49:37 +02:00
## Compiz < 0.9 ##
2011-07-16 23:05:45 +02:00
if test -d " $HOME /.config/compiz " ; then # compiz < 0.9
2014-08-17 20:49:37 +02:00
echo "Compiz: old version detected"
2011-06-20 10:09:54 +02:00
# flat file
2011-07-16 23:05:45 +02:00
if test -f " $HOME /.config/compiz/compizconfig/Default.ini " ; then
2014-08-17 20:49:37 +02:00
echo "Compiz: Flat file detected"
2011-07-16 23:05:45 +02:00
sed -i "/as_active_plugins/ s/.*/&;dbus;scale;expo/g" $HOME /.config/compiz/compizconfig/Default.ini
fi
2011-06-20 10:09:54 +02:00
# gconf
2011-07-16 23:05:45 +02:00
if test -n " $GCONFTOOL_CHECK " ; then
2014-08-17 20:49:37 +02:00
echo "Compiz: GConf backend detected"
2011-07-16 23:05:45 +02:00
plugins = ` gconftool-2 -g /apps/compiz/general/allscreens/options/active_plugins`
gconftool-2 -s /apps/compiz/general/allscreens/options/active_plugins --type= list --list-type= string " ${ plugins : 0 : ${# plugins } -1 } ,dbus,scale,expo] " # plug-ins in double are filtered by Compiz.
fi
2011-06-20 10:09:54 +02:00
fi
2014-08-17 20:49:37 +02:00
## Compiz >= 0.9 ##
2011-07-16 23:05:45 +02:00
if test -d " $HOME /.config/compiz-1 " ; then # compiz >= 0.9 => we can have compiz and compiz-1
2014-08-17 20:49:37 +02:00
echo "Compiz: 0.9 version detected (GConf/Flat)"
2011-06-20 10:09:54 +02:00
# plug-ins in double are NO LONGER filtered by Compiz in this version... (and if plugins in double, compiz crashes :) )
2014-08-17 20:49:37 +02:00
## flat file
2011-07-16 23:05:45 +02:00
if test -f " $HOME /.config/compiz-1/compizconfig/Default.ini " ; then
pluginsFlat = ` grep "s0_active_plugins" $HOME /.config/compiz-1/compizconfig/Default.ini`
for i in dbus scale expo; do
if test ` echo $pluginsFlat | grep -c $i ` -eq 0; then
2014-08-17 20:49:37 +02:00
echo " Flat file: Enable ' $i ' plugin "
2011-07-16 23:05:45 +02:00
pluginsFlat = " $pluginsFlat " " $i ; "
sed -i " /s0_active_plugins/ s/.*/& $i ;/g " $HOME /.config/compiz-1/compizconfig/Default.ini
fi
done
2013-09-22 19:37:27 +02:00
2014-08-17 20:49:37 +02:00
# add a staticswitcher (Alt+Tab) if none is enabled and Unity is not running
2013-09-22 19:37:27 +02:00
switcher = ""
2014-08-17 20:49:37 +02:00
for i in unity staticswitcher ring shift switcher; do
2013-09-22 19:37:27 +02:00
if test ` echo $pluginsFlat | grep -c $i ` -gt 0; then
switcher = $i
break
fi
done
if test -z " $switcher " ; then
2014-08-17 20:49:37 +02:00
echo "Flat file: Enable 'staticswitcher' plugin"
2013-09-22 19:37:27 +02:00
pluginsFlat = " $pluginsFlat " "staticswitcher;"
sed -i "/s0_active_plugins/ s/.*/&staticswitcher;/g" $HOME /.config/compiz-1/compizconfig/Default.ini
fi
2011-07-16 23:05:45 +02:00
fi
2014-08-17 20:49:37 +02:00
## gconf
2011-07-16 23:05:45 +02:00
if test -n " $GCONFTOOL_CHECK " ; then
plugins = ` gconftool-2 -g /apps/compiz-1/general/screen0/options/active_plugins`
2012-04-07 02:41:39 +02:00
if test -n " $plugins " ; then
for i in dbus scale expo; do
if test ` echo $plugins | grep -c $i ` -eq 0; then
2014-08-17 20:49:37 +02:00
echo " GConf: Enable ' $i ' plugin "
2014-09-01 20:34:58 +02:00
plugins = " ${ plugins : 0 : ${# plugins } -1 } , $i ] "
2012-04-07 02:41:39 +02:00
gconftool-2 -s /apps/compiz-1/general/screen0/options/active_plugins --type= list --list-type= string " $plugins "
fi
done
2013-09-22 19:37:27 +02:00
2014-08-17 20:49:37 +02:00
# add a staticswitcher (Alt+Tab) if none is enabled and Unity is not running
2013-09-22 19:37:27 +02:00
switcher = ""
2014-08-17 20:49:37 +02:00
for i in unity staticswitcher ring shift switcher; do
2013-09-22 19:37:27 +02:00
if test ` echo $plugins | grep -c $i ` -gt 0; then
switcher = $i
break
fi
done
if test -z " $switcher " ; then
2014-09-01 20:34:58 +02:00
plugins = " ${ plugins : 0 : ${# plugins } -1 } ,staticswitcher] "
2014-08-17 20:49:37 +02:00
echo "GConf: Enable 'staticswitcher' plugin"
2013-09-22 19:37:27 +02:00
gconftool-2 -s /apps/compiz-1/general/screen0/options/active_plugins --type= list --list-type= string " $plugins "
fi
2012-04-07 02:41:39 +02:00
else # it's possible that the gconf is empty
plugins = "[core,composite,opengl,compiztoolbox,decor,vpswitch,snap,mousepoll,resize,place,move,wall,grid,regex,imgpng,session,gnomecompat,animation,fade,staticswitcher,workarounds,scale,expo,ezoom,dbus]"
gconftool-2 -s /apps/compiz-1/general/screen0/options/active_plugins --type= list --list-type= string " $plugins "
fi
2011-07-16 23:05:45 +02:00
fi
2011-06-20 10:09:54 +02:00
fi
2014-08-17 20:49:37 +02:00
## GSettings ##
profile = ` gsettings get org.compiz current-profile | sed -e "s/'//g" `
if test -n " $profile " ; then ## >= Compiz 0.9.11
echo " Compiz: GSettings backend detected (' $profile ' profile) "
# restrict to the current profile except if it's Unity
# => also update Default if the user wants to use the Cairo-Dock session later.
if test " $profile " = "unity" ; then
profiles = "unity Default"
else
profiles = " $profile "
fi
for p in $profiles ; do
plugins = ` gsettings get org.compiz.core:/org/compiz/profiles/$p /plugins/core/ active-plugins`
if test -n " $plugins " ; then
for i in dbus scale expo; do
if test ` echo $plugins | grep -c " ' $i ' " ` -eq 0; then
echo " GSettings: Enable ' $i ' plugin for ' $p ' profile "
2014-09-01 20:34:58 +02:00
plugins = " ${ plugins : 0 : ${# plugins } -1 } , ' $i '] " # remove last char (']') and add the new plugin between quotes + ']'
2014-08-17 20:49:37 +02:00
gsettings set org.compiz.core:/org/compiz/profiles/$p /plugins/core/ active-plugins " $plugins "
fi
done
# add a staticswitcher (Alt+Tab) if none is enabled and Unity is not running
switcher = ""
for i in unity staticswitcher ring shift switcher; do
if test ` echo $plugins | grep -c " ' $i ' " ` -gt 0; then
switcher = $i
break
fi
done
if test -z " $switcher " ; then
2014-09-01 20:34:58 +02:00
plugins = " ${ plugins : 0 : ${# plugins } -1 } , 'staticswitcher'] "
2014-08-17 20:49:37 +02:00
echo " GSettings: Enable 'staticswitcher' plugin for ' $p ' profile "
gsettings set org.compiz.core:/org/compiz/profiles/$p /plugins/core/ active-plugins " $plugins "
fi
else
echo " GSettings: enable default plugins for ' $p ' profile "
plugins = "['core', 'composite', 'opengl', 'compiztoolbox', 'decor', 'vpswitch', 'snap', 'mousepoll', 'resize', 'place', 'move', 'wall', 'grid', 'regex', 'imgpng', 'session', 'gnomecompat', 'animation', 'fade', 'workarounds', 'scale', 'expo', 'ezoom', 'dbus', 'staticswitcher']"
gsettings set org.compiz.core:/org/compiz/profiles/$p /plugins/core/ active-plugins " $plugins "
fi
done
fi
2011-06-19 01:32:55 +02:00
fi
exit 0