Code Sample |
#!/bin/bash # flux2icewm.bash # convert fluxbox menu to icewm menu # mikshaw 2006 INPOOT="$HOME/.fluxbox/menu" OUTPOOT="$HOME/.icewm/menu" echo "Writing menu to $OUTPOOT" cat $INPOOT | egrep -v "#|^ *$" | while read LINE; do TYPE=`echo $LINE | sed 's/(.*$//;s/^[ \t]//;s/[ \t]$//;s/^\[//;s/\]$//'` LABEL=`echo $LINE | sed 's/^.*]//;s/{.*$//;s/^[ \t]//;s/[ \t]$//;s/^(//;s/)$//'` COMMAND=`echo $LINE | sed 's/^.*)//;s/^[ \t]//;s/[ \t]$//'|grep {*}|sed 's/^\{//;s/\}$//'` ICON=`echo $COMMAND | awk '{print $1}'` case $TYPE in begin) SUBS=0 echo "prog \"Rebuild menu\" - xterm -e /opt/icewm/bin/flux2icewm" > $OUTPOOT ;; submenu) SUBS=$(($SUBS+1)) echo "menu \"$LABEL\" folder {" >> $OUTPOOT ;; separator) echo "separator" >> $OUTPOOT ;; exec) echo "prog \"$LABEL\" $ICON $COMMAND" >> $OUTPOOT echo -n "." ;; restart) echo "restart \"$LABEL\" $ICON $COMMAND" >> $OUTPOOT ;; end*) if [ $SUBS -gt 0 ]; then SUBS=$(($SUBS-1)) echo "}" >> $OUTPOOT else echo " done." fi ;; esac done |