# $Id$ # todo wallpaper? # what does this plugin provide? provide fluxbox # helper helper_rebuild_fluxbox_menu() { local MMINCLUDE local CONFIG MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include" CONFIG="${MMINCLUDE}" clearconfig for file in ${MCORE_CONFIG_PATH}/fluxbox/menu/* do addconfig "[include] (${file})" done # rebuild the user menu too atm CONFIG="${MCORE_UNPRIV_HOME}/.fluxbox/menu" if [[ ! -d ${MCORE_UNPRIV_HOME}/.fluxbox ]] then install -o ${MCORE_UNPRIV_USER} -o ${MCORE_UNPRIV_GROUP} -d ${MCORE_UNPRIV_HOME}/.fluxbox fi # fluxbox menu header clearconfig local ver="$(< /etc/mageversion)" addconfig "[begin] (mCore-${ver} #${MCORE_SERIAL})" # add a newline (maybe there is no crlf in the header) addconfig # our specific menu include addconfig "[include] (${MMINCLUDE})" # fluxbox menu footer addconfig '[nop] (__________)' 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_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="${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 } # 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 "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_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 x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" else eechoe "Theme '${theme}' does not exist!" fi } 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 }