Cleaned up code further

This commit is contained in:
Maxim Stewart 2015-12-10 02:20:28 -06:00
parent 4129854d57
commit aba04f35b4
2 changed files with 99 additions and 78 deletions

View File

@ -16,3 +16,33 @@ clear
fi fi
} }
main main
2>"${INPUT}"
menuitem=$(<"${INPUT}")
case $menuitem in
Main_Menu) bash /bin/shellMen ;;
esac
2>"${INPUT}"
menuitem=$(<"${INPUT}")
case $menuitem in
Main_Menu) bash /bin/shellMen ;;
esac
2>"${INPUT}"
menuitem=$(<"${INPUT}")
case $menuitem in
Main_Menu) bash /bin/shellMen ;;
esac
2>"${INPUT}"
menuitem=$(<"${INPUT}")
case $menuitem in
Main_Menu) bash /bin/shellMen ;;
esac
2>"${INPUT}"
menuitem=$(<"${INPUT}")
case $menuitem in
Main_Menu) bash /bin/shellMen ;;
esac
2>"${INPUT}"
menuitem=$(<"${INPUT}")
case $menuitem in
Main_Menu) bash /bin/shellMen ;;
esac

147
shellMen
View File

@ -20,7 +20,12 @@
pre() pre()
{ {
if [ -d /tmp/sysMENU/ ]; then accss="Accessories" util="Utility" media="Multimedia" vid="Video"
audio="Audio" dev="Development" gme="Game" net="Network"
int="Internet" graph="Graphics" offce="Office" sys="System"
settngs="Settings" wine="Wine" pth="/tmp/sysMENU"
if [ -d "${pth}"/ ]; then
mainMENU; mainMENU;
else else
startScan; startScan;
@ -45,16 +50,16 @@ INPUT=/tmp/menu.txt
Wine "Windows Exe & Program Support" 2>"${INPUT}" Wine "Windows Exe & Program Support" 2>"${INPUT}"
menuitem=$(<"${INPUT}") menuitem=$(<"${INPUT}")
case $menuitem in case $menuitem in
Accessories) bash /tmp/sysMENU/Accessories.sh ;; Accessories) bash "${pth}"/Accessories.sh ;;
System) bash /tmp/sysMENU/System.sh ;; System) bash "${pth}"/System.sh ;;
Settings) bash /tmp/sysMENU/Settings.sh ;; Settings) bash "${pth}"/Settings.sh ;;
Multimedia) bash /tmp/sysMENU/Multimedia.sh ;; Multimedia) bash "${pth}"/Multimedia.sh ;;
Graphics) bash /tmp/sysMENU/Graphics.sh ;; Graphics) bash "${pth}"/Graphics.sh ;;
Games) bash /tmp/sysMENU/Game.sh ;; Games) bash "${pth}"/Game.sh ;;
Office) bash /tmp/sysMENU/Office.sh ;; Office) bash "${pth}"/Office.sh ;;
Development) bash /tmp/sysMENU/Development.sh ;; Development) bash "${pth}"/Development.sh ;;
Internet) bash /tmp/sysMENU/Internet.sh ;; Internet) bash "${pth}"/Internet.sh ;;
Wine) bash /tmp/sysMENU/Wine.sh ;; Wine) bash "${pth}"/Wine.sh ;;
Exit) echo "Bye!"; break ;; Exit) echo "Bye!"; break ;;
esac esac
} }
@ -62,131 +67,117 @@ INPUT=/tmp/menu.txt
startScan() startScan()
{ {
clear clear
accss="Accessories" mkdir "${pth}"
util="Utility" touch "${pth}"/menu.list ;
media="Multimedia" sed -i "d" "${pth}"/menu.list ;
vid="Video" ls /usr/share/applications/ >> "${pth}"/menu.list ;
audio="Audio"
dev="Development"
gme="Game"
net="Network"
int="Internet"
graph="Graphics"
offce="Office"
sys="System"
settngs="Settings"
wine="Wine"
mkdir /tmp/sysMENU
touch /tmp/sysMENU/menu.list ;
sed -i "d" /tmp/sysMENU/menu.list ;
ls /usr/share/applications/ >> /tmp/sysMENU/menu.list ;
header=$(echo "#!/bin/bash header='#!/bin/bash
INPUT=/tmp/menu.txt INPUT=/tmp/menu.txt
dialog --clear --backtitle "\"Shellmen"\" \\ dialog --clear --backtitle "Shellmen" \
--title "\"[ S U B - M E N U ]"\" \\ --title "[ S U B - M E N U ]" \
--menu "\"Please Select An Option"\" 15 50 10 \\ --menu "Please Select An Option" 15 50 10 \
Main_Menu "\"Goes To Main Menu"\" \\") Main_Menu "Goes To Main Menu" \'
echo "$header" > /tmp/sysMENU/${accss}.sh echo "$header" > "${pth}"/${accss}.sh
echo "$header" > /tmp/sysMENU/${dev}.sh echo "$header" > "${pth}"/${dev}.sh
echo "$header" > /tmp/sysMENU/${gme}.sh echo "$header" > "${pth}"/${gme}.sh
echo "$header" > /tmp/sysMENU/${int}.sh echo "$header" > "${pth}"/${int}.sh
echo "$header" > /tmp/sysMENU/${graph}.sh echo "$header" > "${pth}"/${graph}.sh
echo "$header" > /tmp/sysMENU/${offce}.sh echo "$header" > "${pth}"/${offce}.sh
echo "$header" > /tmp/sysMENU/${media}.sh echo "$header" > "${pth}"/${media}.sh
echo "$header" > /tmp/sysMENU/${sys}.sh echo "$header" > "${pth}"/${sys}.sh
echo "$header" > /tmp/sysMENU/${settngs}.sh echo "$header" > "${pth}"/${settngs}.sh
echo "$header" > /tmp/sysMENU/${wine}.sh echo "$header" > "${pth}"/${wine}.sh
menuHeaderInsert; menuHeaderInsert;
} }
menuHeaderInsert() menuHeaderInsert()
{ {
x=$(cat /tmp/sysMENU/menu.list | wc -l) >> /dev/null ; x=$(cat "${pth}"/menu.list | wc -l) >> /dev/null ;
i="1" i="1"
while [ $i -le $x ]; do while [ $i -le $x ]; do
# Reads the number of lines in list.txt then sets as a variable counting up to variable x # Reads the number of lines in list.txt then sets as a variable counting up to variable x
line1=$(sed -n "${i}p" /tmp/sysMENU/menu.list); line1=$(sed -n "${i}p" "${pth}"/menu.list);
filename="${line1%.*}" filename="${line1%.*}"
execMethod=$(grep -A 0 "Exec=" /usr/share/applications/"$line1") execMethod=$(grep -A 0 "Exec=" /usr/share/applications/"$line1")
catagory=$(grep -A 0 "Categories=" /usr/share/applications/"$line1") catagory=$(grep -A 0 "Categories=" /usr/share/applications/"$line1")
preComment=$(grep -A 0 "Comment=" /usr/share/applications/"$line1") preComment=$(grep -A 0 "Comment=" /usr/share/applications/"$line1")
comment=$(sed s/"Comment="//g <<< ${preComment}) comment=$(sed s/"Comment="//g <<< ${preComment})
inputer=$(echo "$filename "\"$comment"\" \\") inputer=$(echo ""\"$filename"\" "\"$comment"\" \\")
if [[ "$catagory" == *"$accss"* ]] || [[ "$catagory" == *"$util"* ]]; then if [[ "$catagory" == *"$accss"* ]] || [[ "$catagory" == *"$util"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${accss}.sh echo "$inputer" >> "${pth}"/${accss}.sh
elif [[ "$catagory" == *"$dev"* ]]; then elif [[ "$catagory" == *"$dev"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${dev}.sh echo "$inputer" >> "${pth}"/${dev}.sh
elif [[ "$catagory" == *"$gme"* ]]; then elif [[ "$catagory" == *"$gme"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${gme}.sh echo "$inputer" >> "${pth}"/${gme}.sh
elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then
echo "$inputer" >> /tmp/sysMENU/${int}.sh echo "$inputer" >> "${pth}"/${int}.sh
elif [[ "$catagory" == *"$graph"* ]]; then elif [[ "$catagory" == *"$graph"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${graph}.sh echo "$inputer" >> "${pth}"/${graph}.sh
elif [[ "$catagory" == *"$offce"* ]]; then elif [[ "$catagory" == *"$offce"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${offce}.sh echo "$inputer" >> "${pth}"/${offce}.sh
elif [[ "$catagory" == *"$media*" ]] \ elif [[ "$catagory" == *"$media*" ]] \
|| [[ "$catagory" == *"$vid"* ]] \ || [[ "$catagory" == *"$vid"* ]] \
|| [[ "$catagory" == *"$audio"* ]]; then || [[ "$catagory" == *"$audio"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${media}.sh echo "$inputer" >> "${pth}"/${media}.sh
elif [[ "$catagory" == *"$sys"* ]]; then elif [[ "$catagory" == *"$sys"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${sys}.sh echo "$inputer" >> "${pth}"/${sys}.sh
elif [[ "$catagory" == *"$settngs"* ]]; then elif [[ "$catagory" == *"$settngs"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${settngs}.sh echo "$inputer" >> "${pth}"/${settngs}.sh
elif [[ "$catagory" == *"$wine"* ]]; then elif [[ "$catagory" == *"$wine"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${wine}.sh echo "$inputer" >> "${pth}"/${wine}.sh
fi fi
i=$[$i++1]; i=$[$i++1];
done done
echo "2>"\"'${INPUT}'"\"" | tee -a /tmp/sysMENU/*.sh echo "2>"\"'${INPUT}'"\"" | tee -a "${pth}"/*.sh
echo 'menuitem=$(<"${INPUT}")' | tee -a /tmp/sysMENU/*.sh echo 'menuitem=$(<"${INPUT}")' | tee -a "${pth}"/*.sh
echo "case \$menuitem in" | tee -a /tmp/sysMENU/*.sh echo "case \$menuitem in" | tee -a "${pth}"/*.sh
echo "Main_Menu) bash /bin/shellMen ;;" | tee -a /tmp/sysMENU/*.sh echo "Main_Menu) exec shellMen ;;" | tee -a "${pth}"/*.sh
commandInsert; commandInsert;
} }
commandInsert() commandInsert()
{ {
x=$(cat /tmp/sysMENU/menu.list | wc -l) >> /dev/null ; x=$(cat "${pth}"/menu.list | wc -l) >> /dev/null ;
i="1" i="1"
while [ $i -le $x ]; do while [ $i -le $x ]; do
line1=$(sed -n "${i}p" /tmp/sysMENU/menu.list); line1=$(sed -n "${i}p" "${pth}"/menu.list);
filename="${line1%.*}" filename="${line1%.*}"
execMethod=$(grep -A 0 "Exec=" /usr/share/applications/"$line1") execMethod=$(grep -A 0 "Exec=" /usr/share/applications/"$line1")
catagory=$(grep -A 0 "Categories=" /usr/share/applications/"$line1") catagory=$(grep -A 0 "Categories=" /usr/share/applications/"$line1")
preComment=$(grep -A 0 "Comment=" /usr/share/applications/"$line1") preComment=$(grep -A 0 "Comment=" /usr/share/applications/"$line1")
execCMD=$(echo "${filename}) exec ${filename} & ;;") execCMD=$(echo "${filename}) exec ${filename} ;;")
if [[ "$catagory" == *"$accss"* ]] || [[ "$catagory" == *"$util"* ]]; then if [[ "$catagory" == *"$accss"* ]] || [[ "$catagory" == *"$util"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${accss}.sh echo "$execCMD" >> "${pth}"/${accss}.sh
elif [[ "$catagory" == *"$dev"* ]]; then elif [[ "$catagory" == *"$dev"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${dev}.sh echo "$execCMD" >> "${pth}"/${dev}.sh
elif [[ "$catagory" == *"$gme"* ]]; then elif [[ "$catagory" == *"$gme"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${gme}.sh echo "$execCMD" >> "${pth}"/${gme}.sh
elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then
echo "$execCMD" >> /tmp/sysMENU/${int}.sh echo "$execCMD" >> "${pth}"/${int}.sh
elif [[ "$catagory" == *"$graph"* ]]; then elif [[ "$catagory" == *"$graph"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${graph}.sh echo "$execCMD" >> "${pth}"/${graph}.sh
elif [[ "$catagory" == *"$offce"* ]]; then elif [[ "$catagory" == *"$offce"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${offce}.sh echo "$execCMD" >> "${pth}"/${offce}.sh
elif [[ "$catagory" == *"$media*" ]] \ elif [[ "$catagory" == *"$media*" ]] \
|| [[ "$catagory" == *"$vid"* ]] \ || [[ "$catagory" == *"$vid"* ]] \
|| [[ "$catagory" == *"$audio"* ]]; then || [[ "$catagory" == *"$audio"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${media}.sh echo "$execCMD" >> "${pth}"/${media}.sh
elif [[ "$catagory" == *"$sys"* ]]; then elif [[ "$catagory" == *"$sys"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${sys}.sh echo "$execCMD" >> "${pth}"/${sys}.sh
elif [[ "$catagory" == *"$settngs"* ]]; then elif [[ "$catagory" == *"$settngs"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${settngs}.sh echo "$execCMD" >> "${pth}"/${settngs}.sh
elif [[ "$catagory" == *"$wine"* ]]; then elif [[ "$catagory" == *"$wine"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${wine}.sh echo "$execCMD" >> "${pth}"/${wine}.sh
fi fi
i=$[$i++1]; i=$[$i++1];
done done
echo "esac" | tee -a /tmp/sysMENU/*.sh echo "esac" | tee -a "${pth}"/*.sh
chmod +x /tmp/sysMENU/*.sh chmod +x "${pth}"/*.sh
mainMENU; mainMENU;
} }
pre; pre;