151 lines
3.1 KiB
Bash
Executable file
151 lines
3.1 KiB
Bash
Executable file
#!/bin/sh
|
|
##!/bin/bash
|
|
# gnome-panel-config - add/remove panels, applets and objects
|
|
# under script control, makes handling gconf slightly less tedious...
|
|
#
|
|
# Copyright (C) 2008 Frank de Lange <gnome-f@unternet.org>
|
|
# licensed under the GNU General Public License v3 or later
|
|
|
|
# defaults and settings
|
|
tool=gconftool-2
|
|
root=/apps/panel
|
|
applets=/general/applet_id_list
|
|
panels=/general/toplevel_id_list
|
|
objects=/general/object_id_list
|
|
|
|
current_applets=$($tool --get $root$applets|sed -e 's#^\[##;s#\]$##')
|
|
current_panels=$($tool --get $root$panels|sed -e 's#^\[##;s#\]$##')
|
|
current_objects=$($tool --get $root$objects|sed -e 's#^\[##;s#\]$##')
|
|
|
|
help () {
|
|
cat<<-"END"
|
|
|
|
gnome-panel-config adds/removes panels, applets and objects
|
|
|
|
-l list panels, applets and objects
|
|
-p <name> add panel <name>
|
|
-a <name> add applet <name>
|
|
-o <name> add object <name>
|
|
-P <name> remove panel <name>
|
|
-A <name> remove applet <name>
|
|
-O <name> remove object <name>
|
|
-c <config> configure element using <config>
|
|
|
|
<config> is a comma-separated string of
|
|
gconf types,keys and values. Leave out the
|
|
leading '/apps/panel' from the key string:
|
|
[list-]type,key,value
|
|
|
|
examples:
|
|
|
|
disable animations:
|
|
gnome-panel-config -c "boolean,/global/enable_animations,false"
|
|
|
|
create a vertical panel on the left side:
|
|
gnome-panel-config -p left -c "string,/toplevels/left/orientation,left"
|
|
|
|
delete that panel:
|
|
gnome-panel-config -P left
|
|
|
|
disable some applets globally:
|
|
gnome-panel-config -c "list-string,/global/disabled_applets,\
|
|
OAFIID:GNOME_SomeApplet,OAFIID:GNOME_SomeOtherApplet"
|
|
|
|
END
|
|
exit
|
|
}
|
|
|
|
list () {
|
|
echo "panels: $current_panels"
|
|
echo "applets: $current_applets"
|
|
echo "objects: $current_objects"
|
|
}
|
|
|
|
add () {
|
|
echo $1${1:+,}$2
|
|
}
|
|
|
|
remove () {
|
|
echo $1|sed -e "s#,*$2##g"
|
|
}
|
|
|
|
config () {
|
|
type=$(echo $1|cut -d ',' -f 1)
|
|
key=$(echo $1|cut -d ',' -f 2)
|
|
value=$(echo $*|cut -d ',' -f 3-)
|
|
IFS= list_type=$(echo $type|cut -d '-' -f 2 -s)
|
|
if [ "x$list_type" = "x" ]; then
|
|
$tool --set --type=$type $root$key $value
|
|
else
|
|
$tool --set --type=list --list-type=$list_type $root$key '['$value']'
|
|
fi
|
|
}
|
|
|
|
add_panel () {
|
|
new_panels=$(add $current_panels $1)
|
|
current_panels=$new_panels
|
|
config list-string,$panels,$current_panels
|
|
}
|
|
|
|
remove_panel () {
|
|
new_panels=$(remove $current_panels $1)
|
|
current_panels=$new_panels
|
|
config list-string,$panels,$current_panels
|
|
}
|
|
|
|
add_applet () {
|
|
new_applets=$(add $current_applets $1)
|
|
current_applets=$new_applets
|
|
config list-string,$applets,$current_applets
|
|
}
|
|
|
|
remove_applet () {
|
|
new_applets=$(remove $current_applets $1)
|
|
current_applets=$new_applets
|
|
config list-string,$applets,$current_applets
|
|
}
|
|
|
|
add_object () {
|
|
new_objects=$(add $current_objects $1)
|
|
current_objects=$new_objects
|
|
config list-string,$objects,$current_objects
|
|
}
|
|
|
|
remove_object () {
|
|
new_objects=$(remove $current_objects $1)
|
|
current_objects=$new_objects
|
|
config list-string,$objects,$current_objects
|
|
}
|
|
|
|
while getopts "hp:a:P:A:c:l" OPTION
|
|
do
|
|
case $OPTION in
|
|
h)
|
|
help
|
|
;;
|
|
p)
|
|
add_panel $OPTARG
|
|
;;
|
|
a)
|
|
add_applet $OPTARG
|
|
;;
|
|
P)
|
|
remove_panel $OPTARG
|
|
;;
|
|
A)
|
|
remove_applet $OPTARG
|
|
;;
|
|
o)
|
|
add_object $OPTARG
|
|
;;
|
|
O)
|
|
remove_object $OPTARG
|
|
;;
|
|
c)
|
|
config $OPTARG
|
|
;;
|
|
l)
|
|
list
|
|
;;
|
|
esac
|
|
done
|