You are not logged in.
Pages: 1
Hi,
A short while ago I wrote a BASH script to generate my Fluxbox menus. The reason being is that most of the RT Audio applications I have installed don't seem to be added or are added to the menus in a way I don't like so much.
It works by using lists of all the names + commands of all the applications I expect to be using. It stores these lists in BASH arrays. It generates submenus into different files. Has a safe logout menu item to prevent you from accidentally logging out, and using devilspie creates a bright red decoration-less xterm requesting the password to shutdown (ie for using sudo halt).
It only adds menu items for applications it can find using 'which'.
It finally creates a system menu as a submenu for all those other applications you'll also want to use.
Ignore some of the comments within it.
#!/bin/bash
echo "Fluxbox menu creator for Linux Audio Users"
echo "******************************************"
echo "version 0.0.1 Sun Jan 23 21:23:40 GMT 2011"
echo " by james w. morris"
echo " http://jwm-art.net"
echo " jwm.art.net@gmail.com"
echo
if which fluxbox &> /dev/null;
then
echo "Fluxbox is installed on this system... Good"
else
echo "Fluxbox is not installed on this system... Bad"
exit
fi
echo
HOST=`hostname`
MENUTITLE="Arch Linux on $HOST"
TERM="xterm"
TERMINAL="Xterm"
INTERM="$TERM -e"
#SHUTDOWNCMD="xterm -geometry 40x2+700+400 -bg red -T Shutdown -e sudo -p 'Password for shutdown:' halt"
# if devilspie is running and xterm.ds exists
#(if (is (application_name) "Shutdown")
#(begin
# center
# undecorate
# above
# pin
#))
# use the following SHUTDOWNCMD instead:
SHUTDOWNCMD="xterm -geometry 40x2 -bg red -T Shutdown -e sudo -p 'Password for shutdown:' halt"
FLUXDIR=~/.fluxbox
SYSMENU=$FLUXDIR/menu
FLUXMENU=$FLUXDIR/my-menu
LOGOUTMENU=$FLUXDIR/my-logout-menu
AUDIOMENU=$FLUXDIR/my-audio-menu
VIDEOMENU=$FLUXDIR/my-video-menu
BRISTOLMENU=$FLUXDIR/my-bristol-menu
LINUXDSPMENU=$FLUXDIR/my-linuxdsp-menu
AUDIOANAMENU=$FLUXDIR/my-audioanalysis-menu
MEDIAMENU=$FLUXDIR/my-media-menu
#---------------------------------------------------------------------
# Applications
#
# you should never remove applications from these lists
# they should only ever be added to the list
# the routines only add those applications from the lists
# which exist on the system.
#
# listing format:
#
# APP_GROUP=(
# "command1,name"
# "--"
# "+submenu_file,name"
# "!fluxbox_command,name"
# )
#
# notes:
# **** "--" creates a menu separator.
# **** the command should not be specified with path.
# **** whitespace must not be placed between command and comma.
# **** whitespace after the comma is removed.
# **** the * character must not be used.
# **** round brackets in the name will be replaced as fluxbox can't handle them.
APPS=(
"--"
"$TERM, $TERMINAL"
"firefox, Firefox"
"nedit, NEdit"
"--"
"xterm -geometry 80x30 -e alsamixer, Alsamixer"
"+$AUDIOMENU, Audio"
"--"
"+$VIDEOMENU, Video"
"+$MEDIAMENU, Media"
"--"
"$INTERM htop, HTop"
"geeqie, Geeqie"
"gqview, GQview"
"--"
"+$SYSMENU, System Menu"
"--"
"+$LOGOUTMENU, Logout"
"$SHUTDOWNCMD, Shutdown"
"--"
)
LOGOUT=(
"!nop, No"
"!exit, Yes"
)
AUDIO_APPS=(
"--"
"qjackctl, qJackCTL"
"patchage, Patchage"
"--"
"ardour2, Ardour2"
"audacity, Audacity"
"mhwaveedit, mhWaveEdit"
"snd, SND"
"timemachine, Time Machine"
"traverso, Traverso"
"--"
"arpage, Arpage"
"gmidimonitor, GMIDImonitor"
"jack-keyboard, Jack Keyboard"
"vmpk, Virtual Midi Keyboard"
"--"
"epichord, Epichord"
"hydrogen, Hydrogen Drum Machine"
"lmms, LMMS"
"muse, MusE"
"non-daw, Non DAW"
"non-sequencer, Non Sequencer"
"qtractor, Qtractor"
"rosegarden, Rosegarden"
"seq24, Seq24"
"--"
"guitarix, Guitarix"
"gx_head, gx_head"
"jack-rack, Jack Rack"
"+$LINUXDSPMENU, LinuxDSP"
"non-mixer, Non Mixer"
"rakarrack, Rakkarack"
"zita-at1, Zita Autotune"
"zita-eq1, Zita Equalizer"
"zita-rev1, Zita Reverb"
"--"
"+$AUDIOANAMENU, Analysis"
"--"
"freecycle, Freecycle"
"qsampler, Linux Sampler"
"slgui, SooperLooper"
"specimen, Specimen Sampler"
"stretchplayer, Stretch Player"
"tapeutape, Tapeutape"
"--"
"aeolus, Aeolus"
"ams, Alsa Modular Synth"
"+$BRISTOLMENU, Bristol"
"foo-yc20, Foo-YC20"
"hexter, Hexter"
"ingen -eg, Ingen"
"machina_gui, Machina"
"minicomputer, Mini Computer"
"mx44, MX44"
"phasex, Phasex"
"qsynth, Qsynth"
"spiralsynthmodular, Spiral Synth Modular"
"yoshimi -j, Yoshimi (JACK MIDI)"
"yoshimi -a, Yoshimi (ALSA MIDI)"
"zynaddsubfx, ZynAddSubFX"
"--"
)
AUDIO_ANA_APPS=(
"--"
"bitmeter, JACK Bit Meter"
"jaaa -A, ALSA Audio Analyser"
"japa -A, ALSA Perceptual Analyser"
"jaaa -J, JACK Audio Analyser"
"japa -J, JACK Perceptual Analyser"
"jkmeter, JACK K Meter"
"jnoisemeter, JACK Noise Meter"
"yass, Yet Another Scrolling Scope"
"--"
)
LINUXDSP_APPS=(
"--"
"sr-2a, SR2A Stereo Reverb"
"ch-eq2, CH-EQ2 Stereo Parametric EQ"
"gr-eq2, GR-EQ2 Stereo Graphic Equaliser"
"vc2, VC2 Stereo Vintage Compressor"
"odv2, ODV2 Stereo Valve Overdrive"
"jp1, JP1 JACK Patchbay"
"ph1, PH-1 Guitar Phaser"
"st1, ST-1 Guitar Sustain"
"dt1, DT-1 Guitar Distortion"
"--"
)
VIDEO_APPS=(
"--"
"cinelerra, Cinelerra"
"lives, Lives"
"--"
)
MEDIA_APPS=(
"--"
"aqualung -c Aqualung1, Aqualung1"
"aqualung -c Aqualung2, Aqualung2"
"smplayer, SMPlayer"
"vlc, VLC media player"
"xmms, XMMS"
"--"
)
BRISTOL=(
"startBristol -mini, moog mini"
"startBristol -explorer, moog voyager"
"startBristol -voyager, moog voyager electric blue"
"startBristol -memory, moog memory"
"startBristol -sonic6, moog sonic 6"
"startBristol -mg1, moog/realistic mg-1 concertmate"
"startBristol -hammond, hammond module (deprecated, use -b3)"
"startBristol -b3, hammond B3 (default)"
"startBristol -prophet, sequential circuits prophet-5"
"startBristol -pro52, sequential circuits prophet-5/fx"
"startBristol -pro10, sequential circuits prophet-10"
"startBristol -pro1, sequential circuits pro-one"
"startBristol -rhodes, fender rhodes mark-I stage 73"
"startBristol -rhodesbass, fender rhodes bass piano"
"startBristol -roadrunner, crumar roadrunner electric piano"
"startBristol -bitone, crumar bit 01"
"startBristol -bit99, crumar bit 99"
"startBristol -bit100, crumar bit + mods"
"startBristol -stratus, crumar stratus synth/organ combo"
"startBristol -trilogy, crumar trilogy synth/organ/string combo"
"startBristol -obx, oberheim OB-X"
"startBristol -obxa, oberheim OB-Xa"
"startBristol -axxe, arp axxe"
"startBristol -odyssey, arp odyssey"
"startBristol -arp2600, arp 2600"
"startBristol -solina, arp/solina string ensemble"
"startBristol -polysix, korg polysix"
"startBristol -poly800, korg poly-800"
"startBristol -monopoly, korg mono/poly"
"startBristol -ms20, korg ms20 (unfinished: -libtest only)"
"startBristol -vox, vox continental"
"startBristol -voxM2, vox continental super/300/II"
"startBristol -juno, roland juno-60"
"startBristol -jupiter, roland jupiter-8"
"startBristol -bme700, baumann bme-700"
"startBristol -bm, bristol bassmaker sequencer"
"startBristol -dx, yamaha dx-7"
"startBristol -cs80, yamaha cs-80 (unfinished)"
"startBristol -sidney, commodore-64 SID chip synth"
"startBristol -melbourne, commodore-64 SID polysynth (unfinished)"
"startBristol -granular, granular synthesiser (unfinished)"
"startBristol -aks, ems synthi-a (unfinished)"
"startBristol -mixer, 16 track mixer (unfinished: -libtest only)"
)
#----------------------------------------------
# function: get_cmd_and_str
# usage:
# get_cmd_and_str "command,textual name of command"
# returns:
# CMD="command"
# STR="textual name of command"
function get_cmd_and_str
{
CMDSTR=$1
# find index of comma within CMDSTR
IX=`expr index "$CMDSTR" ","`
if [ "$IX" -eq 0 ]
then
echo "***** Missing comma in $CMDSTR *****"
exit 0
fi
#and set CMD to text up and including it:
CMD="${CMDSTR::`expr index "$CMDSTR" ","`}"
# set STR to the string after the comma:
STR="${CMDSTR#$CMD}"
# strip whitespace from beginning of STR:
STR=`echo "$STR" | sed 's/^[\t ]*//;s/ *$//' | tr "()" "{}"`
# remove comma from CMD:
CMD="${CMD%,}"
if [[ "${CMD:0:8}" == "$INTERM" ]]
then
CMD=${CMD:9}
XTCMD=1
else
XTCMD=0
fi
# separate options from command:
OPTSIX=`expr index "$CMD" " "`
if [ "$OPTSIX" -eq 0 ]
then
unset CMDOPTS
else
CMDOPTS="${CMD:$OPTSIX}"
(( OPTSIX-- ))
CMD="${CMD::$OPTSIX}"
fi
}
#----------------------------------------------
function create_menu
{
MTITLE=$1
MFILE=$2
declare -a MAPPS=("${!3}")
echo
echo "Creating $MTITLE sub menu..."
echo "[begin] ($MTITLE)" > $MFILE
echo "[encoding] {UTF-8}" >> $MFILE
(IFS=*; for APPSTR in ${MAPPS[@]}
do
if [ "${APPSTR}" == "--" ]
then
echo "[separator]" >> $MFILE
else
get_cmd_and_str $APPSTR
if [ "${APPSTR:0:1}" == "+" ]
then
echo "Adding sub menu for $STR"
echo "[submenu] (${STR})" >> $MFILE
echo "[include] (${CMD:1})" >> $MFILE
echo "[end]" >> $MFILE
else
if [ "${APPSTR:0:1}" == "!" ]
then
echo "Adding fluxbox command for $STR"
echo "[${CMD:1}] (${STR})" >> $MFILE
else
# detect command existence on system:
PCMD=`which $CMD 2> /dev/null`
if [ $? == 0 ]
then
# detect if command should run in terminal:
if [ "${XTCMD}" -eq 0 ]
then
FULLCMD="$PCMD $CMDOPTS"
else
FULLCMD="$INTERM $PCMD"
fi
echo "Adding $FULLCMD"
echo "[exec] ($STR) {$FULLCMD}" >> $MFILE
else
echo "skipping $CMD..."
fi
fi
fi
fi
done )
}
create_menu "$MENUTITLE" "$FLUXMENU" APPS[@]
create_menu "Logout" "$LOGOUTMENU" LOGOUT[@]
create_menu "Audio" "$AUDIOMENU" AUDIO_APPS[@]
create_menu "Video" "$VIDEOMENU" VIDEO_APPS[@]
create_menu "Media" "$MEDIAMENU" MEDIA_APPS[@]
create_menu "Bristol" "$BRISTOLMENU" BRISTOL[@]
create_menu "LinuxDSP" "$LINUXDSPMENU" LINUXDSP_APPS[@]
create_menu "Analysis" "$AUDIOANAMENU" AUDIO_ANA_APPS[@]
#----------------------------------------------
# Figure out how to create the system menu
#----------------------------------------------
echo "Creating system sub menu..."
if which mmaker &> /dev/null;
then
mmaker --stdout --skip=Xfce fluxbox > $SYSMENU
else
if which fluxbox-generate_menu &> /dev/null
then
fluxbox-generate_menu
else
cp /etc/X11/fluxbox/fluxbox-menu ~/.fluxbox/menu
fi
fi
Last edited by jwm-art (2011-02-01 10:35:21)
Offline
This should probably be moved to the Community Contributions forum.
Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.
Offline
Moving....
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
Pages: 1