#!/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@@" ICON_SUFFIX="@@ICON_SUFFIX@@" die() { echo "ERROR: $@"; exit 1; } # very basic getops for i in $* do case $1 in --resource|-r) shift; icon_resource="$1" ;; --name|-n) shift; argv_name="$1" ;; --command|-c) shift; argv_command="$1" ;; --icon|-i) shift; argv_icon="$1" ;; --filename|-f) shift; argv_filename="$1" ;; --xres|-x) shift; argv_xres="$1" ;; --yres|-y) shift; argv_yres="$1" ;; --icon-width|-w) shift; argv_iwidth="$1" ;; --icon-height|-h) shift; argv_iheight="$1" ;; --default-icon) shift; argv_deficon="$1" ;; esac shift done # some sanity checks: if [[ -n ${icon_resource} ]] then [[ -f ${icon_resource} ]] || die "Icon resource '${icon_resource}' does not exist" else name="${argv_name}" command="${argv_command}" filename="${argv_filename}" xres="${argv_xres}" yres="${argv_yres}" icon="${argv_icon}" deficon="${argv_deficon}" iwidth="${argv_iwidth}" iheight="${argv_iheight}" # 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 ${MCORE_LIBDIR}/idesk-generate-icon-info \ --name "${name}" \ --command "${command}" \ --icon "${icon}" \ --filename "${filename}" \ --xres "${xres}" \ --yres "${yres}" \ --icon-width "${iwidth}" \ --icon-height "${iheight}" \ --default-icon "${deficon}" icon_resource="${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}" fi source "${icon_resource}" # icon resource overrides [[ -n ${argv_name} ]] && name="${argv_name}" [[ -n ${argv_command} ]] && command="${argv_command}" [[ -n ${argv_filename} ]] && filename="${argv_filename}" [[ -n ${argv_xres} ]] && xres="${argv_xres}" [[ -n ${argv_yres} ]] && yres="${argv_yres}" [[ -n ${argv_icon} ]] && icon="${argv_icon}" [[ -n ${argv_deficon} ]] && deficon="${argv_deficon}" [[ -n ${argv_iwidth} ]] && iwidth="${argv_iwidth}" [[ -n ${argv_iheight} ]] && iheight="${argv_iheight}" [[ -z ${filename} ]] && die "Error \$filename is empty in icon resource '${icon_resource}'" # get the right icon path, local overrides global [[ -f ${GLOBAL_PIXMAPS_PATH}/${icon} ]] && icon_path="${GLOBAL_PIXMAPS_PATH}" [[ -f ${LOCAL_PIXMAPS_PATH}/${icon} ]] && icon_path="${LOCAL_PIXMAPS_PATH}" # no icon found, use default icon if [[ -z ${icon_path} ]] then icon_path="${GLOBAL_PIXMAPS_PATH}" icon="default.png" fi CONFIG="${MCORE_UNPRIV_HOME}/.idesktop/${filename}.${ICON_SUFFIX}" clearconfig addconfig 'table Icon' addconfig " Caption: ${name}" addconfig " Command: ${command}" addconfig " Icon: ${icon_path}/${icon}" addconfig " X: ${xres}" addconfig " Y: ${yres}" # add these only if not zero if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]] then addconfig " Width: ${iwidth}" addconfig " Height: ${iheight}" fi addconfig 'end'