#!/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" if [[ $(whoami) = ${MCORE_UNPRIV_USER} ]] then x11runas="" sudo="sudo" else x11runas="x11runas" sudo="" fi RUN_IDESK=1 case $1 in --no-startup|-n) RUN_IDESK=0 ;; esac # 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} if [ -f /usr/share/idesk/dot.ideskrc ] then install -m0644 /usr/share/idesk/dot.ideskrc "${rc}" fi chown "${MCORE_UNPRIV_USER}":"${MCORE_UNPRIV_GROUP}" ${dest} # clean default reboot,shutdown,sysinfo icon info for i in shutdown reboot sysinfo do ${sudo} ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${i}" 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 ${sudo} ${MCORE_LIBDIR}/idesk-generate-icon \ --add \ --name "${name}" \ --command "sudo @@SBINDIR@@/${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}" if [[ ${RUN_IDESK} = 1 ]] then # restart idesk if [[ -n $(pidof idesk) ]] then killall idesk fi if [[ -z ${x11runas} ]] then nohup idesk > /dev/null & else ${x11runas} "nohup idesk > /dev/null &" fi fi