Topic: Custom dmenu-bind.sh
Updates
# 09.29.2009 -- Submenu support addedThis is my personal dmenu-bind.sh, pretty easy to understand and modify. There is also a fast command to edit itself with gedit.
Is there any hope to see it being default? And what about having me write a little script with obxml to convert the default obmenu to commands for dmenu?
Discuss,
lordkrandel
#!/bin/bash
# Custom dmenu-bind.sh
#
# Copyright 2009, Gatti Paolo (lordkrandel at gmail dot com)
# Distributed as public domain.
# 09.28.2009 -- First release
# 09.29.2009 -- Submenu support added
if [ "$1" == "" ]; then
title="MainMenu"
menu=( \
# labels commands
# Main =========================================
web "$0 web"
system "$0 system"
tools "$0 tools"
settings "$0 settings"
)
else
case $1 in
web)
title="web"
menu=( \
# Web ==========================================
firefox "firefox" \
lostirc "lostirc" \
)
;;
tools)
title="tools"
menu=( \
# Tools ========================================
gedit "gedit" \
geditsudo "gksudo gedit" \
)
;;
system)
title="system"
menu=( \
# System =======================================
home "pcmanfm" \
tilda "tilda" \
synaptic "gksudo synaptic" \
)
;;
settings)
title="settings"
menu=( \
# Settings =====================================
volume "$0 volume" \
dmenu "gedit $0" \
obconf "obconf" \
)
;;
volume)
title="Volume"
menu=( \
# Volume controls ==============================
0% "amixer sset Master 0" \
50% "amixer sset Master 50" \
70% "amixer sset Master 70" \
100% "amixer sset Master 100" \
)
;;
esac
fi
for (( count = 0 ; count < ${#menu[*]}; count++ )); do
# build two arrays, one for labels, the other for commands
temp=${menu[$count]}
if (( $count < ${#menu[*]}-2 )); then
temp+="\n"
fi
if (( "$count" % 2 == "0" )); then
menu_labels+=$temp
else
menu_commands+=$temp
fi
done
select=`echo -e $menu_labels | dmenu -p $title -nb black -nf white -sb darkblue -sf white`
if [ "$select" != "" ]; then
# fetch and clean the index of the selected label
index=`echo -e "${menu_labels[*]}" | grep -xnm1 $select | sed 's/:.*//'`
# get the command which has the same index
part=`echo -e ${menu_commands[*]} | head -$index`
exe=`echo -e "$part" | tail -1`
# execute
$exe &
fiLast edited by lordkrandel (2009-09-29 12:58:30)