Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'd like to know How can I remove all the applets from a given panel in MATE (in my case the bottom panel) from the command-line.

The panel should be left in a clean state, meaning no applets just the panel. Pretty much the opposite of what I did here. I believe the answer I got here should have some clues of what to do, but then again I'm not good at scripting.

How would I go about doing it?.

share|improve this question
    
LOL, another 500? Joking. I will update a script here. Happy Holiday. –  John Siu Dec 26 '12 at 2:46
    
Hell yeah, serves for motivation I suppose :P, Thanks. Happy Holidays. –  Uri Herrera Dec 26 '12 at 2:48
    
LOL, done!!!!!! –  John Siu Dec 26 '12 at 2:59
    
Thanks. I'll probably need more help with MATE though. –  Uri Herrera Dec 26 '12 at 3:15
    
I will always try :) I have multiple accounts using mate as default WM now, lol –  John Siu Dec 26 '12 at 3:16
add comment

1 Answer 1

up vote 2 down vote accepted

It is actually the same script. But WITHOUT the panel deletion part. I also change *DEL_PANEL* to *TARGET_PANEL* to avoid confusion.

TARGET_PANEL is the panel name of panel to be altered.

#!/bin/bash

PANEL_PATH="${HOME}/.mateconf/apps/panel"
TARGET_PANEL='bottom_panel_screen0'

    echo 'DEBUG: Panel Path' ${PANEL_PATH}
    echo 'DEBUG: Panel to be altered' ${TARGET_PANEL}

# - APPLETS
# -- Identify applet to be deleted

cd ${PANEL_PATH}/applets
DEL_APPLET=`grep -r ${TARGET_PANEL} *|cut -d\/ -f1`

    echo 'DEBUG: DEL_APPLET' ; for i in ${DEL_APPLET} ; do echo -e "DEBUG: \t${i}" ; done

# -- Get old applet id list

APPLET_ID_LIST_OLD=`mateconftool-2 -g /apps/panel/general/applet_id_list | cut -d\[ -f2 | cut -d\] -f1 | sed 's/,/ /g'`

    echo 'DEBUG: Old applet_id_list' ${APPLET_ID_LIST_OLD}

# -- Generate new applet id list

APPLET_ID_LIST_NEW=''
for i in ${APPLET_ID_LIST_OLD}
do
    if [[ "$DEL_APPLET" != *"${i}"* ]]
    then
        echo -e "DEBUG: \tKeep ${i}"
        APPLET_ID_LIST_NEW="${APPLET_ID_LIST_NEW} ${i}"
    else
        echo -e "DEBUG: \tDel  ${i}"
        # -- Delete applet folder
        rm -rf ${PANEL_PATH}/applets/${i}
    fi
done
APPLET_ID_LIST_NEW="[`echo ${APPLET_ID_LIST_NEW} | sed 's/ /,/g'`]"

# -- Apply new applet id list
mateconftool-2 -s /apps/panel/general/applet_id_list -t list --list-type=string "${APPLET_ID_LIST_NEW}"

    echo 'DEBUG: New applet_id_list' `mateconftool-2 -g /apps/panel/general/applet_id_list`


# - OBJECTS
# -- Identify object to be deleted

cd ${PANEL_PATH}/objects
DEL_OBJECT=`grep -r ${TARGET_PANEL} *|cut -d\/ -f1`

    echo 'DEBUG: DEL_OBJECT' ; for i in ${DEL_OBJECT} ; do echo -e "DEBUG: \t${i}" ; done

# -- Get old object id list

OBJECT_ID_LIST_OLD=`mateconftool-2 -g /apps/panel/general/object_id_list | cut -d\[ -f2 | cut -d\] -f1 | sed 's/,/ /g'`

    echo 'DEBUG: Old object_id_list' ${OBJECT_ID_LIST_OLD}

# -- Generate new object id list

OBJECT_ID_LIST_NEW=''
for i in ${OBJECT_ID_LIST_OLD}
do
    if [[ "$DEL_OBJECT" != *"${i}"* ]]
    then
        echo -e "DEBUG:\tKeep ${i}"
        OBJECT_ID_LIST_NEW="${OBJECT_ID_LIST_NEW} ${i}"
    else
        echo -e "DEBUG:\tDel  ${i}"
        # -- Delete object folder
        rm -rf ${PANEL_PATH}/objects/${i}
    fi
done
OBJECT_ID_LIST_NEW="[`echo ${OBJECT_ID_LIST_NEW} | sed 's/ /,/g'`]"

# -- Apply new object id list
mateconftool-2 -s /apps/panel/general/object_id_list -t list --list-type=string "${OBJECT_ID_LIST_NEW}"

    echo 'DEBUG: New applet_id_list' `mateconftool-2 -g /apps/panel/general/object_id_list`
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.