如何从 MATE 面板中删除所有小程序?

如何从 MATE 面板中删除所有小程序?

我想知道如何从命令行删除 MATE 中给定面板(在我的情况下是底部面板)的所有小程序。

面板应保持干净状态,即没有小程序,只有面板。与我在这里做了什么。 我相信我在这里得到的答案应该有一些关于该做什么的线索,但是我又不擅长编写脚本。

我该如何去做呢?

答案1

其实是一样的脚本。但没有面板删除部分。我还更改了删除面板目标面板以避免混淆。

目标面板是要改变的面板的面板名称。

#!/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`

相关内容