Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (3) </ 1 [2] 3 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Debian Menu for DSL, Script Testers Needed< Next Oldest | Next Newest >
cbagger01 Offline





Group: Members
Posts: 4264
Joined: Oct. 2003
Posted: June 01 2005,17:49 QUOTE

Thanks to everyone who is testing and providing information.

I installed circuslinux (Debian Testing) and got the same menu entry.

I then examined the /usr/lib/menu file for further information and found out there is an (optional) variable to a menu entry called "longtitle", in addition to the regular "title" entry, and since both names end with the letters TITLE, it confuses things somewhat.

So I will need to rework the script to ignore "longtitle" and focus on "title".

I'll post the next revision when it is ready for testing.

Thanks again for the feedback.  It is appreciated.
Back to top
Profile PM 
cbagger01 Offline





Group: Members
Posts: 4264
Joined: Oct. 2003
Posted: June 02 2005,03:11 QUOTE

OK,

Give this revision a try.  It should filter out all of the longtitles and you should see "Circus Linux" in the menu and the one with the exclamation point should no longer be there.

Code Sample
#!/bin/bash
#
# build_debmenu.sh  -   Creates a Fluxbox Debian submenu with menu items for
#                       all Debian packages that add an entry into the
#                       /usr/lib/menu directory
# Rev 1 6/01/05
# by cbagger01 from the DSL forums

# Copy the existing fluxbox menu file and strip out
# the old debmenu submenu entries and save to a temp file
cat $HOME/.fluxbox/menu | grep -v debmenu  > /tmp/oldmenu

# Find the line number directly above the (Apps) submenu
linenum=`awk '/\(Apps\)/ { print NR }' /tmp/oldmenu`
let "prevnum = linenum - 1"

# Create the first part of the new menu file
sed -n '1,'$prevnum'p' /tmp/oldmenu > /tmp/newmenu

# Create the Debian fluxbox submenu entry
echo "   [submenu] (Debian) {} # debmenu" >> /tmp/newmenu

# Collect the Debian Menu titles
# Our Debian friends do not use a consistent delimiter method for the
# title value.  If the title contains spaces, it is enclosed in quotes and
# the delimiters are START: title=" and END: "  but if the title doesn't
# contain spaces, then no quotes are used and the delimiters
# are START: title= and END: blankspace
# This sed script will parse out the title values properly regardless
# of the method used inside each menu file
cat /usr/lib/menu/* 2> /dev/null | \
sed -e 's/.*longtitle//' \
-e 's/.*title=\([^"]*\) .*/title=\1/g' \
-e 's/.*title="\([^"]*\)".*/title=\1/g' \
-n -e 's/title=//p' > /tmp/titles

# Collect the Debian Menu commands
# The same issue exists with the command value because some command strings
# will contain spaces, for example "/bin/ls -al"
cat /usr/lib/menu/* 2> /dev/null | \
sed -e 's/.*command=\([^"]*\) .*/command=\1/g' \
-e 's/.*command="\([^"]*\)".*/command=\1/g' \
-n -e 's/command=//p' > /tmp/commands

# Loop through each title / command pair and build a menu entry
i=1
total=`awk 'END { print NR }' /tmp/titles`
while [ "$i" -le $total ];do
title=`sed -n "$i"p /tmp/titles`
command=`sed -n "$i"p /tmp/commands`
# Create the new fluxbox menu entry
echo "      [exec]  ($title) {$command} # debmenu" >> /tmp/newmenu
let "i+=1"
done

# Close out the Debian fluxbox submenu
echo "   [end] # debmenu" >> /tmp/newmenu

# Add the rest of the old menu to the end of our new menu
sed -n $linenum',$p' /tmp/oldmenu >> /tmp/newmenu

# This script may be running effective as root under sudo
# If so, figure out the real user name
realuser=
if [ -z "$SUDO_USER" ]; then
realuser=$USER
else
realuser=$SUDO_USER
fi

# Change the menu file permissions if real user is not root
if [ "$realuser" != "root" ]; then
chown $realuser:staff /tmp/newmenu
fi

# Replace the fluxbox menu file with our newly built file
mv /tmp/newmenu $HOME/.fluxbox/menu

# Clean up old temp files
rm -rf /tmp/oldmenu
rm -rf /tmp/titles
rm -rf /tmp/commands

exit
Back to top
Profile PM 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: June 02 2005,04:54 QUOTE

Once this is thoroughly tested it would make a nice addition to the dpkg-restore.dsl
Back to top
Profile PM WEB 
clivesay Offline





Group: Guests
Posts: 935
Joined: Dec. 2003
Posted: June 02 2005,13:26 QUOTE

You scripters just blow my mind!

If this was in dsl-dpkg we would have mydsl and debian apt dynamic menu building in fluxbox?!! We don't need no stinkin' KDE or Gnome :)

Chris
Back to top
Profile PM MSN YIM 
friedgold Offline





Group: Members
Posts: 122
Joined: Mar. 2005
Posted: June 05 2005,15:53 QUOTE

I'm going to try giving this a go today. Definately a big win being able to have the fluxbox menus automatically updated.

Out of interest was there any reason the debian update-menus program (part of the debian menu package) couldn't be used/modified instead of writing a completely new script?
Back to top
Profile PM 
14 replies since May 23 2005,04:19 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (3) </ 1 [2] 3 >/
reply to topic new topic new poll
Quick Reply: Debian Menu for DSL

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code