#!/bin/bash MCORE_LIBDIR="@@MCORE_LIBDIR@@" source @@SYSCONFDIR@@/mcore/mcore.conf source ${MCORE_LIBDIR}/include/common.global.class GLOBAL_PIXMAPS_PATH="@@GLOBAL_PIXMAPS_PATH@@" LOCAL_PIXMAPS_PATH="${MCORE_CONFIG_PATH}/icons/default" ICON_INFO_PATH="${MCORE_CONFIG_PATH}/icons/info" ICON_INFO_SUFFIX="@@ICON_INFO_SUFFIX@@" die() { echo "ERROR: $@"; exit 1; } # very basic getops for i in $* do case $1 in --add|--del|--print) method="${1//--}" ;; --name|-n) shift; name="$1" ;; --command|-c) shift; command="$1" ;; --icon|-i) shift; icon="$1" ;; --filename|-f) shift; filename="$1" ;; --xres|-x) shift; xres="$1" ;; --yres|-y) shift; yres="$1" ;; --icon-width|-w) shift; iwidth="$1" ;; --icon-height|-h) shift; iheight="$1" ;; --default-icon) shift; deficon="$1" ;; esac shift done # some sanity checks: [[ -z ${method} ]] && die "No method given" case ${method} in add) # abort if name or command not given [[ -z ${name} ]] && die "No name given" [[ -z ${command} ]] && die "No command given" [[ -z ${filename} ]] && filename="${name}" # use some defaults for icon, dest, {x,y}res [[ -z ${xres} ]] && xres=50 [[ -z ${yres} ]] && yres=50 if [[ -z ${icon} ]] then # if no default icon is given use default.png [[ -z ${deficon} ]] && deficon="default.png" icon="${deficon}" fi CONFIG="${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}" clearconfig addconfig "name=\"${name}\"" addconfig "filename=\"${filename}\"" addconfig "command=\"${command}\"" addconfig "icon=\"${icon}\"" addconfig "deficon=\"${deficon}\"" addconfig "xres=\"${xres}\"" addconfig "yres=\"${yres}\"" if [[ ! -z ${iwidth} ]] then addconfig "iwidth=\"${iwidth}\"" fi if [[ ! -z ${iheight} ]] then addconfig "iheight=\"${iheight}\"" fi ;; del) [[ -z ${name} ]] && die "No name given" [[ -z ${filename} ]] && filename="${name}" if [[ -f ${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX} ]] then rm "${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}" fi ;; print) list_files_in_directory "${ICON_INFO_PATH}" ;; esac