# $Id$ provide idesk basic-icons helper_generate_icon() { local name local icon local command local dest local yres local xres local iwidth local iheight local deficon local CONFIG local utility # very basic getops for i in $* do case $1 in --name|-n) shift; name="$1" ;; --command|-c) shift; command="$1" ;; --icon|-i) shift; icon="$1" ;; --dest|-d) shift; dest="$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: # abort if name or command not given [[ -z ${name} ]] && return 1 [[ -z ${command} ]] && return 1 [[ -z ${dest} ]] && dest="${MCORE_UNPRIV_HOME}/.idesktop/${name}.lnk" # use some defaults for icon, dest, {x,y}res [[ -z ${xres} ]] && xres=50 [[ -z ${yres} ]] && xres=50 if [[ -z ${icon} ]] || [ ! -f ${icon} ] then # if no default icon is given use default.png [[ -z ${deficon} ]] && deficon="default.png" icon="@@PIXMAPSDIR@@/${deficon}" fi CONFIG="${dest}" clearconfig addconfig 'table Icon' addconfig " Caption: ${name}" addconfig " Command: ${command}" addconfig " Icon: ${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' } helper_generate_all_desktop_icons() { local session_list="$1" local other_menuitem_list="$2" local plugin_list="$3" local res local xres local yres local x local y local i local name local progsh_path local utility local dest local rc dest="${MCORE_UNPRIV_HOME}/.idesktop" rc="${MCORE_UNPRIV_HOME}/.ideskrc" # progs path progsh_path="${MCORE_UNPRIV_HOME}/.progs" # get the resolution res=$(mysqldo "select resolution from cfg_graphic where serial='${MCORE_SERIAL}'") # split res to x & y xres="${res%x*}" yres="${res#*x}" # 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} # default settings declare -i x=50 declare -i y=50 # ica icons for i in ${session_list} do # abort if empty [[ -z ${i} ]] && continue # get database information evaluate_table cfg_sessions "where serial='${MCORE_SERIAL}' and id='${i}'" # 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 generate_icon \ --name "${cfg_sessions_session}" \ --command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \ --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \ --dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \ --xres "${x}" \ --yres "${y}" y=$((${y} + 80)) done for i in ${other_menuitem_list} do # abort if empty [[ -z ${i} ]] && continue # get database information evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'" # 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 generate_icon \ --name "${cfg_other_menuitems_name}" \ --command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \ --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_name}).png" \ --dest "${dest}/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \ --xres "${x}" \ --yres "${y}" \ --default-icon "default_item.png" y=$((${y} + 80)) done for i in ${plugin_list} do # abort if empty [[ -z ${i} ]] && continue evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] then eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem) # abort if name or exec is empty [[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue [[ -z ${PLUGIN_MENUITEM_EXEC} ]] && 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 generate_icon \ --name "${PLUGIN_MENUITEM_NAME}" \ --command "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \ --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).png" \ --dest "${dest}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).lnk" \ --xres "${x}" \ --yres "${y}" \ --default-icon "default_item.png" y=$((${y} + 80)) fi # unset all variables unset PLUGIN_MENUITEM_NAME unset PLUGIN_MENUITEM_EXEC unset PLUGIN_MENUITEM_PARAM unset PLUGIN_MENUITEM_WORKDIR unset PLUGIN_MENUITEM_ICON 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" ;; reboot) name="Neustarten" ;; esac generate_icon \ --name "${name}" \ --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \ --icon "${ALX_SESSIONS_ICONS}/${i}.png" \ --dest "${dest}/${i}.lnk" \ --xres "${x}" \ --yres "${y}" \ --icon-width "40" \ --icon-height "40" y=$((${y} + 80)) done # last but not least gen a icon with some sys informations local sysinfo local hostname local osversion osversion="$(< /etc/mageversion)" hostname=$(mysqldo "select hostname from cfg_network where serial='${ALX_SERIAL}'") sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" # now get the right position: # restore orig values of xres xres="$(( ${xres} + 120 ))" # default y pos (full yres -22 = cur yres + 58 !) yres="$(( ${yres} + 58 ))" # middle of the screen # (no txt - length required, xtdesk manage that itself) xres="$(( ${xres} / 2))" generate_icon \ --name "${sysinfo}" \ --command "exit 0" \ --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ --dest "${dest}/sysinfo.lnk" \ --xres "${xres}" \ --yres "${yres}" \ --icon-width "1" \ --icon-height "1" }