You are not logged in.
Pages: 1
I've switched to awesome-git and really enjoy the cleanliness of the wm.
So I've been looking for a bash/zsh or any other script to run as a "menu", where you be able to have a structure similar to kmenu or gnome with the ability to move up and down and return to the root menu. Think openbox menu in a shell.
I'm suprised to not find anything on the web as I would think it's easy to impliment.
Has anyone seen anything like this?
I have seen dmenu and it's not for me, I'd rather have it in a shell assigned to a keybinding.
If this doen't exist, what's the best way to impliment it?
I'm slowly learning a little python, and want to learn more about shell scripting.
Last edited by corstar (2009-01-26 07:51:22)
Offline
zsh has a menu for the completion system, at least.
>zomg picture<
Anyway, you can always hack something together with python + (n)curses
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
There is pdmenu in AUR
And with some scripting you can make a menu in dialog.
Offline
.. or go the total leet way and don't use a menu at all, gmrun/bashmenu/dmenu/.. is better :-)
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
Or xbindkeys
Offline
Hmm... Is awesome's built in menu really far from what you want? Well... besides from that it's not in a shell that is.
Last edited by Zeist (2008-11-15 16:19:55)
I haven't lost my mind; I have a tape back-up somewhere.
Twitter
Offline
Hmm... Is awesome's built in menu really far from what you want? Well... besides from that it's not in a shell that is.
I didn't know there was a built in menu, can you tell me about it? (unless you mean M+f1)
Like that old geek idiom, I want to do it just because it can be done.
This would be cool to run games etc from the terminal proper.
Another reason, I read somewhere a while ago that you could run apps (the article refered to wine apps) from the tty without logging into X.
Apparently, a certain command sructure opens a bare X session and closes it when you quit the X application.
It might be a pipe dream, but I will at least learn more about bash as I go.
Last edited by corstar (2008-11-16 23:29:44)
Offline
So, I've been watching some awesome video tutorials from Linux CBT, specifically the bash shell scripting.
I really want to get my project on the way. So I have a very alpha version of what I want.
So far I have implemented a:
* welcome message
* short list of applications. (some X, some cli)
* dropping back to the (script) menu with the ability to quit
* a leaving message and 3 second pause when quiting
* clearing the screen when dropping to bash
in the short term, I'd like to add the ability for the user to add a new menu entry through a menu choice.
ie: first add name, then provide a binary path
in the long term, I'd like to have a auto config type of option that would work like update-menus(?) for openbox etc.
Please give feedback on what you think. Here's the code:
#!/bin/bash
# Author: Cory Pollard
# Mail to: corypollard@gmail.com
# Date: 2009.01.26
# Purpose: An attempt to create a kmenu or gnome menu setup within bash.
# Eventually, I'd like to give the user the ablility to add menu names and binary
# paths via an option in the menu. That way it's customizable for the end user.
#BEGIN
clear
figlet Welcome!
PS3='Please make a selection: '
LIST="wine_config midnight_commander inkscape battleship the_cows_opinion quit"
select i in $LIST
do
if [ $i = "wine_config" ]
then
/usr/bin/winecfg
elif [ $i = "midnight_commander" ]
then
/usr/bin/mc
elif [ $i = "inkscape" ]
then
/usr/bin/inkscape
elif [ $i = "battleship" ]
then
/usr/bin/bs
elif [ $i = "the_cows_opinion" ]
then
cowsay Got Milk?
elif [ $i = "quit" ]
then
figlet Thanks !!!
sleep 2s
clear
break
fi
done
#END
Offline
Nice idea. Just for fun I've played with your script and came up with this:
menu.sh:
#!/bin/bash
# Author: Cory Pollard
# Mail to: corypollard@gmail.com
# Date: 2009.01.26
# Purpose: An attempt to create a kmenu or gnome menu setup within bash.
# Eventually, I'd like to give the user the ablility to add menu names and binary
# paths via an option in the menu. That way it's customizable for the end user.
#BEGIN
clear
figlet Welcome!
PS3='Please make a selection: '
MENU=()
COMMANDS=()
ENTRIES=()
# read MENU from file in $1
source $1
# Odd elements of MENU go into ENTRIES, even elements into COMMANDS
for (( i=0; i<${#MENU[@]}; i+=2 )); do
ENTRIES[${#ENTRIES[@]}]=${MENU[$i]}
COMMANDS[${#COMMANDS[@]}]=${MENU[$i+1]}
done
# Print Menu
for (( i=0; i<${#ENTRIES[@]}; i++ )); do
ENTRY=${ENTRIES[$i]}
INDEX=$i; let INDEX+=1
echo "$INDEX) $ENTRY"
done
while true; do
CHOICE=""
# read CHOICE until it's a digit and within range of entries
until [[ $CHOICE =~ [0-9] && CHOICE -lt ${#ENTRIES[@]}+1 ]]; do
echo -n -e "\r$PS3"
read -s -n1 CHOICE
done
# get COMMAND
COMMAND=${COMMANDS[$CHOICE-1]}
if [ "$COMMAND" == "QUIT" ]; then
echo
figlet Thanks !!!
sleep 2s
clear
break
elif [[ "$COMMAND" =~ ^MENU\ (.+) ]]; then
exec sh menu.sh ${BASH_REMATCH[1]}
# invoke COMMAND
elif [ "$COMMAND" != "" ]; then
`$COMMAND > /dev/null 2>&1` &
fi
done
#END
main.sh (contains the "main" menu):
MENU=(
"Web Browser" "/usr/bin/firefox"
"Text Editor" "/usr/bin/emacs"
"Mail Program" "/opt/kde/bin/kmail"
"Sub Menu" "MENU sub.sh"
"Quit" "QUIT"
)
sub.sh (contains a sub menu):
MENU=(
"Sub Menu Entry" "zenity --info --text Submenu Entry 1"
"Back" "MENU main.sh"
)
invoke with "sh menu.sh main.sh"
This solution uses a MENU array which gets sourced from a file given to menu.sh as the first argument. Each file contains a bash Array MENU that defines a specific menu. The "meta" commands "QUIT" and "MENU" either quit or invoke a submenu. The latter is done by exec'ing (that is replacing) the current menu.sh instance with a new instance using the specified menu file. (just a quick and dirty hack). I'm not using select since it's very limited.
Regarding user editing and/or generating menus from XDG menu files or similar sources this is probably not an ideal solution. And littering the files about is also kind of dirty. But maybe this can give you some ideas...
OTOH you might be better of using the dialog(1) program for implementing sth like this.
Offline
hbekel,
Thanks for taking a look at it. I'm only starting out in scripting/programming so it will take me some time to get my head around some coding.
I love what you've done. The sub-menu item is awesome, I wasn't sure how to implement that.
OTOH you might be better of using the dialog(1) program for implementing sth like this.
I hadn't heard of this program, I'll look into it a little more.
Regarding user editing and/or generating menus from XDG menu files or similar sources this is probably not an ideal solution. And littering the files about is also kind of dirty. But maybe this can give you some ideas...
Yeah, I feel the same way. But I was just throwing an idea around to populate the menu quickly.
Thanks again
Offline
Pages: 1