--- mcore-src/trunk/mcore-tools/daemon/client/include/fluxbox.client.class 2011/02/02 21:19:48 1254 +++ mcore-src/trunk/mcore-tools/daemon/client/include/fluxbox.client.class 2012/08/13 10:06:21 2016 @@ -1,5 +1,7 @@ # $Id$ +# todo wallpaper? + # what does this plugin provide? provide fluxbox @@ -8,27 +10,29 @@ { local MMINCLUDE local CONFIG + local file + local ver MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include" - CONFIG="${MMINCLUDE}" + CONFIG="${MROOT}/${MMINCLUDE}" clearconfig - - for file in ${MCORE_CONFIG_PATH}/fluxbox/menu/* + for file in $(find ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu -type f) do + [[ ! -z ${MROOT} ]] && file=$(echo ${file} | sed "s:${MROOT}::") addconfig "[include] (${file})" done # rebuild the user menu too atm - CONFIG="${MCORE_UNPRIV_HOME}/.fluxbox/menu" - if [[ ! -d ${MCORE_UNPRIV_HOME}/.fluxbox ]] + 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 ${MCORE_UNPRIV_HOME}/.fluxbox + install -o ${MCORE_UNPRIV_USER} -o ${MCORE_UNPRIV_GROUP} -d ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox fi # fluxbox menu header clearconfig - local ver="$(< /etc/mageversion)" - addconfig "[begin] (mCore-${ver} #${MCORE_SERIAL})" + ver="$(< ${MROOT}/etc/mageversion)" + addconfig "[begin] (${MCORE_DISTRIBUTION}-${ver} #${MCORE_SERIAL})" # add a newline (maybe there is no crlf in the header) addconfig @@ -37,67 +41,141 @@ addconfig "[include] (${MMINCLUDE})" # fluxbox menu footer - addconfig '[nop] (__________)' - addconfig '[exec] (Neustarten) {sudo reboot}' - addconfig '[exec] (Herunterfahren) {sudo halt}' + 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) addconfig } -help_fluxbox_addmenuitem() +helper_rebuild_fluxbox_autostart() { - mecho "set fluxbox.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" -} - -# set_fluxbox_addmenuitem $name $exec $workdir $icon -set_fluxbox_addmenuitem() -{ - local name="$1" - local exec="$2" - local workdir="$3" - local icon="$4" local CONFIG - [[ -z ${name} ]] && help_session_addmenuitem && return 1 - [[ -z ${exec} ]] && help_session_addmenuitem && return 1 - - CONFIG="${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" + CONFIG="${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/apps" clearconfig - addconfig "[exec] (${name}) {${exec}}" + for file in $(find ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/autostart -type f) + do + addconfig "$(< ${file})" + done + + # add a newline (maybe there is no crlf in the footer) + addconfig +} + +help_fluxbox_menuitem() +{ + 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." +} + +# 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_rebuild_fluxbox_menu } -help_fluxbox_delmenuitem() +# get_fluxbox_menuitem +get_fluxbox_menuitem() { - mecho "set session.delmenuitem [name]" - mecho " Deletes a fluxbox menu entry." - mecho " name - menu entry name" - mecho " If no [name] given, all entries are deleted." + list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu } -# set_fluxbox_delmenuitem [$name] -set_fluxbox_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 ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] - then - rm ${MCORE_CONFIG_PATH}/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 ${MCORE_CONFIG_PATH}/fluxbox/menu/* + x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" + else + eechoe "Theme '${theme}' does not exist!" fi +} - # rebuild the menu now - helper_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 }