--- mcore-src/trunk/mcore-tools/daemon/client/include/session.client.class 2011/02/02 20:20:24 1248 +++ mcore-src/trunk/mcore-tools/daemon/client/include/fluxbox.client.class 2012/08/13 10:02:37 2014 @@ -1,83 +1,180 @@ # $Id$ +# todo wallpaper? + # what does this plugin provide? provide fluxbox # helper -helper_session_rebuild_fluxbox_menu() +helper_rebuild_fluxbox_menu() { - :> ${SETTINGSPATH}/fluxbox/alxmenu + local MMINCLUDE + local CONFIG + + MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include" + CONFIG="${MROOT}/${MMINCLUDE}" + clearconfig - for file in ${SETTINGSPATH}/fluxbox/menu/* + for file in ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/* do - echo "[include] (${file})" >> ${SETTINGSPATH}/fluxbox/alxmenu + [[ ! -z ${MROOT} ]] && file=$(echo ${file} | sed "s:${MROOT}::") + addconfig "[include] (${file})" done # rebuild the user menu too atm - cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu + CONFIG="${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/menu" + if [[ ! -d ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox ]] + then + install -o ${MCORE_UNPRIV_USER} -o ${MCORE_UNPRIV_GROUP} -d ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox + fi - # now fix it with proper messages :P - local ver="$(< /etc/mageversion)" - sed -i "s:@CHANGEME@:tinyALX-${ver} #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu + # fluxbox menu header + clearconfig + local ver="$(< ${MROOT}/etc/mageversion)" + addconfig "[begin] (mCore-${ver} #${MCORE_SERIAL})" # add a newline (maybe there is no crlf in the header) - echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu + addconfig - # our specific include - echo "[include] (${SETTINGSPATH}/fluxbox/alxmenu)" >> ${ALX_UNPRIV_HOME}/.fluxbox/menu + # our specific menu include + addconfig "[include] (${MMINCLUDE})" # fluxbox menu footer - cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu + addconfig '[separator]' + addconfig '[exit] (Abmelden)' + addconfig '[exec] (Neustarten) {sudo /sbin/reboot}' + addconfig '[exec] (Herunterfahren) {sudo /sbin/halt}' + addconfig '[end]' # add a newline (maybe there is no crlf in the footer) - echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu + addconfig } -help_session_addmenuitem() +helper_rebuild_fluxbox_autostart() { - mecho "set session.addmenuitem [name] [exec] [workdir] [icon]" - mecho " adds a fluxbox menu entry" - mecho " name - menu entry name" - mecho " exec - executable to start" - mecho " workdir - working directory for the executable - optional" - mecho " icon - pixmap icon of the entry - optional" + local CONFIG + + CONFIG="${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/apps" + clearconfig + for file in ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/autostart/* + do + addconfig "$(< ${file})" + done + + # add a newline (maybe there is no crlf in the footer) + addconfig } -# set_session_addmenuitem $name $exec $workdir $icon -set_session_addmenuitem() +help_fluxbox_menuitem() { - local name="$1" - local exec="$2" - local workdir="$3" - local icon="$4" + mecho "get fluxbox.menuitem" + mecho " Shows all custom added menuitems of fluxbox." + mecho + mecho "set fluxbox.menuitem [action] [name] [exec] [workdir] [icon]" + mecho " Adds or deletes a fluxbox menu entry." + mecho " Actions:" + mecho " add - adds a menuitem" + mecho " del - deletes a menuitem" + mecho + mecho " name - menu entry name" + mecho " exec - executable to start" + mecho " workdir - working directory for the executable - optional" + mecho " icon - pixmap icon of the entry - optional" + mecho + mecho " If no [name] given, all entries will be deleted." +} - echo "[exec] (${name}) {${exec}}" > ${SETTINGSPATH}/fluxbox/menu/${name} +# set_fluxbox_menuitem $name $exec $workdir $icon +set_fluxbox_menuitem() +{ + local action="$1" + local name="$2" + local exec="$3" + local workdir="$4" + local icon="$5" + local CONFIG + + [[ -z ${action} ]] && help_fluxbox_menuitem && return 1 + + case "${action}" in + add) + [[ -z ${name} ]] && help_fluxbox_menuitem && return 1 + [[ -z ${exec} ]] && help_fluxbox_menuitem && return 1 + CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" + clearconfig + addconfig "[exec] (${name}) {${exec}}" + ;; + del) + if [[ -f ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] + then + rm ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}" + elif [[ -z ${name} ]] + then + # delete all items + rm ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/* + fi + ;; + *) + help_fluxbox_menuitem && return 1 + ;; + esac # rebuild the menu now - helper_session_rebuild_fluxbox_menu + helper_rebuild_fluxbox_menu } -help_session_delmenuitem() +# get_fluxbox_menuitem +get_fluxbox_menuitem() { - mecho "set session.delmenuitem [name]" - mecho " deletes a fluxbox menu entry" - mecho " name - menu entry name" + list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu } -# set_session_delmenuitem [$name] -set_session_delmenuitem() +help_fluxbox_theme() { - local name="$1" + mecho "get fluxbox.theme [method]" + mecho " Displays current installed or system-wide available themes." + mecho " Methods:" + mecho " system - shows systemwide available themes" + mecho " current - shows current selected theme" + mecho + mecho "set fluxbox.theme [theme]" + mecho " Sets a default theme for fluxbox." +} - if [[ -f ${SETTINGSPATH}/fluxbox/menu/${name} ]] - then - rm ${SETTINGSPATH}/fluxbox/menu/${name} - elif [[ -z ${name} ]] +set_fluxbox_theme() +{ + local theme="$1" + local stylesdir="/usr/share/fluxbox/styles" + + [[ -z ${theme} ]] && help_fluxbox_theme && return 1 + [[ ! -x $(which fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1 + + if [[ -e ${stylesdir}/${theme} ]] then - # delete all items - rm ${SETTINGSPATH}/fluxbox/menu/* + x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" + else + eechoe "Theme '${theme}' does not exist!" fi +} - # rebuild the menu now - helper_session_rebuild_fluxbox_menu +get_fluxbox_theme() +{ + local method="$1" + local stylesdir="/usr/share/fluxbox/styles" + local value + local i + + [[ -z ${method} ]] && help_fluxbox_theme && return 1 + + case "${method}" in + system) + list_files_in_directory -type d -mindepth 1 -maxdepth 1 ${MROOT}/${stylesdir} + ;; + + current) + value=$(grep -i '^session.stylefile' ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:') + rvecho "${value}" + ;; + *) help_fluxbox_theme && return 1 ;; + esac }