--- 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 2011/02/04 19:55:56 1257 @@ -1,5 +1,7 @@ # $Id$ +# todo wallpaper? + # what does this plugin provide? provide fluxbox @@ -46,58 +48,128 @@ addconfig } -help_fluxbox_addmenuitem() +help_fluxbox_menuitem() { - 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" + 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 ${name} ]] && help_session_addmenuitem && return 1 - [[ -z ${exec} ]] && help_session_addmenuitem && return 1 + [[ -z ${action} ]] && help_fluxbox_menuitem && return 1 - CONFIG="${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" - clearconfig - addconfig "[exec] (${name}) {${exec}}" + case "${action}" in + add) + [[ -z ${name} ]] && help_fluxbox_menuitem && return 1 + [[ -z ${exec} ]] && help_fluxbox_menuitem && return 1 + CONFIG="${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" + clearconfig + addconfig "[exec] (${name}) {${exec}}" + ;; + del) + if [[ -f ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] + then + rm ${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}" + elif [[ -z ${name} ]] + then + # delete all items + rm ${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() +{ + local i + local item + + for i in $(find ${MCORE_CONFIG_PATH}/fluxbox/menu -type f | sort) + do + item="${item} $(basename ${i})" + done + + mecho "${item}" +} + +help_fluxbox_theme() { - 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." + 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." } -# set_fluxbox_delmenuitem [$name] -set_fluxbox_delmenuitem() +set_fluxbox_theme() { - local name="$1" + local theme="$1" + local stylesdir="/usr/share/fluxbox/styles" - if [[ -f ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] - then - rm ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} - elif [[ -z ${name} ]] + [[ -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) + for i in $(find ${stylesdir} -mindepth 1 -maxdepth 1 | sort) + do + value="${value} $(basename ${i})" + done + mecho "${value}" + ;; + + current) + value=$(grep -i '^session.stylefile' ${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:') + mecho "${value}" + ;; + *) help_fluxbox_theme && return 1 ;; + esac }