Cleaned up code by a lot. Smaller file size....

This commit is contained in:
Maxim Stewart 2015-12-09 23:56:29 -06:00
parent 59fb8f8058
commit d19ee08fb6
2 changed files with 65 additions and 112 deletions

4
install.sh Normal file → Executable file
View File

@ -5,13 +5,13 @@ clear
read -p "Please Press 1 to Install or 2 to Uninstall --> : " INPUT read -p "Please Press 1 to Install or 2 to Uninstall --> : " INPUT
if [ "$INPUT" == 1 ]; then if [ "$INPUT" == 1 ]; then
sudo cp shellMen /bin/ sudo cp shellMen /bin/
sudo chown root:root /bin/shellMen sudo chown root:root /bin/shellMen
sudo chmod +x /bin/shellMen sudo chmod +x /bin/shellMen
elif [ "$INPUT" == 2 ]; then elif [ "$INPUT" == 2 ]; then
sudo rm /bin/shellMen sudo rm /bin/shellMen
elif [ "$INPUT" !== 1 ] || [ "$INPUT" !== 2 ] ; then elif [ "$INPUT" !== 1 ] || [ "$INPUT" !== 2 ] ; then
echo "Please type 1 or 2." echo "Please type 1 or 2."
main main
fi fi
} }
main main

173
shellMen Normal file → Executable file
View File

@ -20,11 +20,11 @@
pre() pre()
{ {
if [ -d /tmp/sysMENU/ ]; then if [ -d /tmp/sysMENU/ ]; then
mainMENU; mainMENU;
else else
startScan; startScan;
fi fi
} }
mainMENU() mainMENU()
@ -65,7 +65,7 @@ clear
accss="Accessories" accss="Accessories"
util="Utility" util="Utility"
media="Multimedia" media="Multimedia"
vid="Video" vid="Video"
audio="Audio" audio="Audio"
dev="Development" dev="Development"
gme="Game" gme="Game"
@ -102,11 +102,11 @@ menuHeaderInsert;
menuHeaderInsert() menuHeaderInsert()
{ {
x=$(cat /tmp/sysMENU/menu.list | wc -l) >> /dev/null ; # Variable set to number of lines filled in list.txt x=$(cat /tmp/sysMENU/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" /tmp/sysMENU/menu.list);
filename="${line1%.*}" filename="${line1%.*}"
execMethod=$(grep -A 0 "Exec=" /usr/share/applications/"$line1") execMethod=$(grep -A 0 "Exec=" /usr/share/applications/"$line1")
@ -115,75 +115,37 @@ i="1"
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" >> /tmp/sysMENU/${accss}.sh
elif [[ "$catagory" == *"$dev"* ]]; then elif [[ "$catagory" == *"$dev"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${dev}.sh echo "$inputer" >> /tmp/sysMENU/${dev}.sh
elif [[ "$catagory" == *"$gme"* ]]; then elif [[ "$catagory" == *"$gme"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${gme}.sh echo "$inputer" >> /tmp/sysMENU/${gme}.sh
elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then
echo "$inputer" >> /tmp/sysMENU/${int}.sh echo "$inputer" >> /tmp/sysMENU/${int}.sh
elif [[ "$catagory" == *"$graph"* ]]; then elif [[ "$catagory" == *"$graph"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${graph}.sh echo "$inputer" >> /tmp/sysMENU/${graph}.sh
elif [[ "$catagory" == *"$offce"* ]]; then elif [[ "$catagory" == *"$offce"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${offce}.sh echo "$inputer" >> /tmp/sysMENU/${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" >> /tmp/sysMENU/${media}.sh
elif [[ "$catagory" == *"$sys"* ]]; then elif [[ "$catagory" == *"$sys"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${sys}.sh echo "$inputer" >> /tmp/sysMENU/${sys}.sh
elif [[ "$catagory" == *"$settngs"* ]]; then elif [[ "$catagory" == *"$settngs"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${settngs}.sh echo "$inputer" >> /tmp/sysMENU/${settngs}.sh
elif [[ "$catagory" == *"$wine"* ]]; then elif [[ "$catagory" == *"$wine"* ]]; then
echo "$inputer" >> /tmp/sysMENU/${wine}.sh echo "$inputer" >> /tmp/sysMENU/${wine}.sh
fi fi
i=$[$i++1]; i=$[$i++1];
done done
endMenuInsert=$(echo "2>"\"'${INPUT}'"\"")
menuitmVar=$(echo 'menuitem=$(<"${INPUT}")') echo "2>"\"'${INPUT}'"\"" | tee -a /tmp/sysMENU/*.sh
preCMD=$(echo "case \$menuitem in") echo 'menuitem=$(<"${INPUT}")' | tee -a /tmp/sysMENU/*.sh
menuCall=$(echo "Main_Menu) bash /bin/shellMen ;;") echo "case \$menuitem in" | tee -a /tmp/sysMENU/*.sh
echo "$endMenuInsert" >> /tmp/sysMENU/${accss}.sh echo "Main_Menu) bash /bin/shellMen ;;" | tee -a /tmp/sysMENU/*.sh
echo "$menuitmVar" >> /tmp/sysMENU/${accss}.sh
echo "$preCMD" >> /tmp/sysMENU/${accss}.sh commandInsert;
echo "$menuCall" >> /tmp/sysMENU/${accss}.sh
echo "$endMenuInsert" >> /tmp/sysMENU/${dev}.sh
echo "$menuitmVar" >> /tmp/sysMENU/${dev}.sh
echo "$preCMD" >> /tmp/sysMENU/${dev}.sh
echo "$menuCall" >> /tmp/sysMENU/${dev}.sh
echo "$endMenuInsert" >> /tmp/sysMENU/${gme}.sh
echo "$menuitmVar" >> /tmp/sysMENU/${gme}.sh
echo "$preCMD" >> /tmp/sysMENU/${gme}.sh
echo "$menuCall" >> /tmp/sysMENU/${gme}.sh
echo "$endMenuInsert" >> /tmp/sysMENU/${int}.sh
echo "$menuitmVar" >> /tmp/sysMENU/${int}.sh
echo "$preCMD" >> /tmp/sysMENU/${int}.sh
echo "$menuCall" >> /tmp/sysMENU/${int}.sh
echo "$endMenuInsert" >> /tmp/sysMENU/${graph}.sh
echo "$menuitmVar" >> /tmp/sysMENU/${graph}.sh
echo "$preCMD" >> /tmp/sysMENU/${graph}.sh
echo "$menuCall" >> /tmp/sysMENU/${graph}.sh
echo "$endMenuInsert" >> /tmp/sysMENU/${offce}.sh
echo "$menuitmVar" >> /tmp/sysMENU/${offce}.sh
echo "$preCMD" >> /tmp/sysMENU/${offce}.sh
echo "$menuCall" >> /tmp/sysMENU/${offce}.sh
echo "$endMenuInsert" >> /tmp/sysMENU/${media}.sh
echo "$menuitmVar" >> /tmp/sysMENU/${media}.sh
echo "$preCMD" >> /tmp/sysMENU/${media}.sh
echo "$menuCall" >> /tmp/sysMENU/${media}.sh
echo "$endMenuInsert" >> /tmp/sysMENU/${sys}.sh
echo "$menuitmVar" >> /tmp/sysMENU/${sys}.sh
echo "$preCMD" >> /tmp/sysMENU/${sys}.sh
echo "$menuCall" >> /tmp/sysMENU/${sys}.sh
echo "$endMenuInsert" >> /tmp/sysMENU/${settngs}.sh
echo "$menuitmVar" >> /tmp/sysMENU/${settngs}.sh
echo "$preCMD" >> /tmp/sysMENU/${settngs}.sh
echo "$menuCall" >> /tmp/sysMENU/${settngs}.sh
echo "$endMenuInsert" >> /tmp/sysMENU/${wine}.sh
echo "$menuitmVar" >> /tmp/sysMENU/${wine}.sh
echo "$preCMD" >> /tmp/sysMENU/${wine}.sh
echo "$menuCall" >> /tmp/sysMENU/${wine}.sh
commandInsert;
} }
commandInsert() commandInsert()
@ -197,43 +159,34 @@ i="1"
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" >> /tmp/sysMENU/${accss}.sh
elif [[ "$catagory" == *"$dev"* ]]; then elif [[ "$catagory" == *"$dev"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${dev}.sh echo "$execCMD" >> /tmp/sysMENU/${dev}.sh
elif [[ "$catagory" == *"$gme"* ]]; then elif [[ "$catagory" == *"$gme"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${gme}.sh echo "$execCMD" >> /tmp/sysMENU/${gme}.sh
elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then
echo "$execCMD" >> /tmp/sysMENU/${int}.sh echo "$execCMD" >> /tmp/sysMENU/${int}.sh
elif [[ "$catagory" == *"$graph"* ]]; then elif [[ "$catagory" == *"$graph"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${graph}.sh echo "$execCMD" >> /tmp/sysMENU/${graph}.sh
elif [[ "$catagory" == *"$offce"* ]]; then elif [[ "$catagory" == *"$offce"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${offce}.sh echo "$execCMD" >> /tmp/sysMENU/${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" >> /tmp/sysMENU/${media}.sh
elif [[ "$catagory" == *"$sys"* ]]; then elif [[ "$catagory" == *"$sys"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${sys}.sh echo "$execCMD" >> /tmp/sysMENU/${sys}.sh
elif [[ "$catagory" == *"$settngs"* ]]; then elif [[ "$catagory" == *"$settngs"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${settngs}.sh echo "$execCMD" >> /tmp/sysMENU/${settngs}.sh
elif [[ "$catagory" == *"$wine"* ]]; then elif [[ "$catagory" == *"$wine"* ]]; then
echo "$execCMD" >> /tmp/sysMENU/${wine}.sh echo "$execCMD" >> /tmp/sysMENU/${wine}.sh
fi fi
i=$[$i++1]; i=$[$i++1];
done done
echo "esac" >> /tmp/sysMENU/${accss}.sh echo "esac" | tee -a /tmp/sysMENU/*.sh
echo "esac" >> /tmp/sysMENU/${dev}.sh chmod +x /tmp/sysMENU/*.sh
echo "esac" >> /tmp/sysMENU/${gme}.sh mainMENU;
echo "esac" >> /tmp/sysMENU/${int}.sh
echo "esac" >> /tmp/sysMENU/${graph}.sh
echo "esac" >> /tmp/sysMENU/${offce}.sh
echo "esac" >> /tmp/sysMENU/${media}.sh
echo "esac" >> /tmp/sysMENU/${sys}.sh
echo "esac" >> /tmp/sysMENU/${settngs}.sh
echo "esac" >> /tmp/sysMENU/${wine}.sh
chmod +x /tmp/sysMENU/*.sh
mainMENU;
} }
pre; pre;