#!/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; } dest="${MCORE_UNPRIV_HOME}/.idesktop" rc="${MCORE_UNPRIV_HOME}/.ideskrc" # progs path progsh_path="${MCORE_UNPRIV_HOME}/.progs" # get the resolution eval $(x11runas xinfo) xres="${xorg_width}" yres="${xorg_height}" # fallback to 1024x768 [[ -z ${xres} ]] && xres="1024" [[ -z ${yres} ]] && xres="768" # top left edge of the icon is given in config file # remove a little bit to simulate the bottom-right edge xres="$(( ${xres} - 120 ))" yres="$(( ${yres} - 80 ))" # clean desktop icon location [ -d ${dest} ] && rm -rf ${dest} [ -f ${rc} ] && rm -f ${rc} install -d ${dest} chown "${MCORE_UNPRIV_USER}":"${MCORE_UNPRIV_GROUP}" ${dest} # clean default reboot,shutdown icon info for i in shutdown reboot do if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/icons/info/${i}.${ICON_INFO_SUFFIX} ] then rm ${MROOT}/${MCORE_CONFIG_PATH}/icons/info/${i}.${ICON_INFO_SUFFIX} fi done # default settings declare -i x=50 declare -i y=50 for icon_resource in $(find ${MROOT}/${MCORE_CONFIG_PATH}/icons/info -type f) do # abort if empty [[ -z ${icon_resource} ]] && continue # new line if x > xres if [ ${x} -ge ${xres} ] then x=50 y=$((${y} + 80)) fi # new row if y > yres if [ ${y} -ge ${yres} ] then x=$((${x} + 120)) y=50 # re-check x [ ${x} -ge ${xres} ] && x=50 fi ${MCORE_LIBDIR}/idesk-generate-icon --add --resource "${icon_resource}" --xpos "${x}" --ypos "${y}" y=$((${y} + 80)) done # add shutdown, reboot icons for i in shutdown reboot do # new line if x > xres if [ ${x} -ge ${xres} ] then x=50 y=$((${y} + 80)) fi # new row if y > yres if [ ${y} -ge ${yres} ] then x=$((${x} + 120)) y=50 # re-check x [ ${x} -ge ${xres} ] && x=50 fi case ${i} in shutdown) name="Herunterfahren"; cmd="poweroff" ;; reboot) name="Neustarten"; cmd="${i}" ;; esac ${MCORE_LIBDIR}/idesk-generate-icon \ --add \ --name "${name}" \ --command "sudo /usr/sbin/${cmd}" \ --icon "${i}.png" \ --filename "${i}" \ --xpos "${x}" \ --ypos "${y}" \ --icon-width "40" \ --icon-height "40" y=$((${y} + 80)) done # generate sysinfo ${MCORE_LIBDIR}/idesk-sysinfo ${MCORE_LIBDIR}/idesk-generate-icon --add \ --resource "${MROOT}/${MCORE_CONFIG_PATH}/icons/info/sysinfo.${ICON_INFO_SUFFIX}" # restart idesk killall idesk; x11runas "nohup idesk > /dev/null &"