mikshaw
Group: Members
Posts: 4856
Joined: July 2004 |
|
Posted: Jan. 20 2006,23:28 |
|
Generate A Personal Menu
Here's a bash script that will generate a menu file ($HOME/.fluxbox/my_menu) which can be included in your fluxbox menu by putting this line somewhere in $HOME/.fluxbox/menu:
Code Sample | [include] (/home/dsl/fluxbox/my_menu) |
In its current state it just adds quick access to editing application config files and scripts, but i'm planning to expand it in the future.
You should edit the variables at the top of the file to reflect your prefered editor and paths.
Code Sample | #!/bin/bash
# Generate a personal menu to add to your regular fluxbox menu. # It is meant specifically for Damn Small Linux, but should work # in most other systems. # # Insert this line into $HOME/.fluxbox/menu: # [include] (MENUFILE) # MENUFILE is listed below # # Changelog (yyyy-mm-dd) # 2006-01-23: cleaned up and reorganized some code # added some files # 2006-01-20: first
################################################ # EDIT THESE VARIABLES TO SUIT YOUR NEEDS: # # The generated menu file MENUFILE=$HOME/.fluxbox/my_menu # # Name of your submenu (displayed in fluxbox menu) MENU_LABEL="my stuff" # # Directory where personal scripts are found MY_SCRIPTS=$HOME/scripts # # Your text editor #MY_EDITOR="aterm -e /opt/vim/bin/vim" MY_EDITOR=beaver # # Other apps HTM_BROWSER=dillo #PDF_VIEWER=xpdf # # Miscellaneous rc files in $HOME for various applications # Be sure to escape any line breaks MISC_RC_FILES=".dillo/dillorc .dillo/cookiesrc .vimrc .wgetrc .xpdfrc .jwmrc \ .torsmorc .xmms/config .xmms/menurc .xtdesktop/xtdeskrc .gtkrc \ .screenrc .xbindkeysrc \ .irssi/config .mplayer/config .mplayer/gui.conf .vnc/xstartup .hydrogen/hydrogen.conf .gftp/gftprc" ################################################
echo "[begin] [submenu] ($MENU_LABEL)" > $MENUFILE || exit 1 echo "[exec] (rebuild menu) {sh $0}" >> $MENUFILE echo "[submenu] (edit configs)" >> $MENUFILE # "Events" [ -r "$HOME/Events" ] && echo "[exec] (Events) {${MY_EDITOR} $HOME/Events}" >> $MENUFILE # fluxbox configuration files if [ -d $HOME/.fluxbox ]; then echo "[submenu] (fluxbox)" >> $MENUFILE for filez in menu menuconfig generate_menu init init-dev keys keys-dev apps \ windowmenu groups slitlist startup fluxter.bb; do if [ -r $HOME/.fluxbox/${filez} ]; then echo "[exec] (${filez}) {${MY_EDITOR} $HOME/.fluxbox/${filez}}" >> $MENUFILE fi done echo "[exec] (current style) {${MY_EDITOR} \`grep styleFile $HOME/.fluxbox/init | cut -f2\`}" >> $MENUFILE echo "[end]" >> $MENUFILE fi # emelfm configuration files if [ -d $HOME/.emelfm ]; then echo "[submenu] (emelfm)" >> $MENUFILE for filez in bookmarks buttons filetypes keys plugins settings toolbar user_commands; do if [ -r $HOME/.emelfm/${filez} ]; then echo "[exec] (${filez}) {${MY_EDITOR} $HOME/.emelfm/${filez}}" >> $MENUFILE fi done echo "[end]" >> $MENUFILE fi # midnight commander configuration files if [ -d $HOME/.mc ]; then echo "[submenu] (mc)" >> $MENUFILE for filez in ini ext bindings menu hotlist; do if [ -r $HOME/.mc/${filez} ]; then echo "[exec] (${filez}) {${MY_EDITOR} $HOME/.mc/${filez}}" >> $MENUFILE fi done echo "[end]" >> $MENUFILE fi # monkey configuration files if [ -d /opt/monkey/conf ]; then echo "[submenu] (monkey)" >> $MENUFILE for filez in modules.conf monkey.conf monkey.deny monkey.mime; do if [ -r /opt/monkey/conf/${filez} ]; then echo "[exec] (${filez}) {sudo ${MY_EDITOR} /opt/monkey/conf/${filez}}" >> $MENUFILE fi done echo "[end]" >> $MENUFILE fi # miscellaneous configs in /opt echo "[submenu] (opt)" >> $MENUFILE for filez in bootlocal.sh powerdown.sh .backup_device .dslrc .mydsl_dir samba/smb.conf apsfilter/apsfilterrc; do if [ -r "/opt/${filez}" ]; then echo "[exec] (${filez}) {sudo ${MY_EDITOR} /opt/${filez}}" >> $MENUFILE fi done echo "[end]" >> $MENUFILE # miscellaneous configs in $HOME subdirectories (MISC_RC_FILES above). echo "[submenu] (other)" >> $MENUFILE for misc_conf in `echo "$MISC_RC_FILES"`; do if [ -r "$HOME/${misc_conf}" ]; then echo "[exec] (${misc_conf}) {${MY_EDITOR} $HOME/${misc_conf}}" >> $MENUFILE fi done echo "[end]" >> $MENUFILE # vital configuration files in ${HOME} for filez in .xinitrc .bashrc .bash_profile .Xdefaults .Xmodmap .profile .xserverrc \ .filetool.lst .xfiletool.lst .webdata.lst .webdatarc .netrc .desktop .background; do if [ -r $HOME/${filez} ]; then echo "[exec] (${filez}) {${MY_EDITOR} $HOME/${filez}}" >> $MENUFILE fi done echo "[end]" >> $MENUFILE #end of "edit configs"
# edit scripts if [ -d ${MY_SCRIPTS} ]; then echo "[submenu] (edit scripts)" >> $MENUFILE for script_type in sh bash flua tcl lua pl; do echo "[submenu] ($script_type)" >> $MENUFILE [ -x ${MY_SCRIPTS}/new_script ] && \ echo "[exec] (new $script_type script) {aterm -e ${MY_SCRIPTS}/new_script ${script_type}}" >> $MENUFILE && \ echo "[separator]" >> $MENUFILE for script in ${MY_SCRIPTS}/*.${script_type}; do [ -x $script ] && trunc_script=`echo $script | awk -F / '{print $NF}'` && \ echo "[exec] (${trunc_script}) {$MY_EDITOR ${script}}" >> $MENUFILE done echo "[end]" >> $MENUFILE done [ -x ${MY_SCRIPTS}/new_script ] && \ echo "[exec] (edit script template) {$MY_EDITOR ${MY_SCRIPTS}/new_script}" >> $MENUFILE && \ echo "[end]" >> $MENUFILE #end of "edit scripts" fi echo "[end]" >> $MENUFILE #end of menu echo "[end]" >> $MENUFILE #end of file echo "Menu written to $MENUFILE."
|
NOTE: The "scripts" part currently works only with scripts that are executable and have filename extensions of sh, bash, tcl, pl, lua, or flua
-------------- http://www.tldp.org/LDP/intro-linux/html/index.html
|