2015-04-09 21:30:24 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# By Maxim F. Stewart
|
|
|
|
# Contact: [maxim2131@gmail.com] OR [gamer1119@gmail.com]
|
|
|
|
#
|
|
|
|
# Copyright 2013 Maxim F. Stewart
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#---------------------------------------------------------------------------------------#
|
2015-07-26 02:55:27 +00:00
|
|
|
|
|
|
|
pre()
|
|
|
|
{
|
2015-12-10 08:20:28 +00:00
|
|
|
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
|
2015-12-10 05:56:29 +00:00
|
|
|
mainMENU;
|
|
|
|
else
|
|
|
|
startScan;
|
|
|
|
fi
|
2015-07-26 02:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mainMENU()
|
|
|
|
{
|
2015-04-09 21:40:36 +00:00
|
|
|
INPUT=/tmp/menu.txt
|
2015-07-26 03:03:49 +00:00
|
|
|
dialog --clear --backtitle "Shellmen" \
|
|
|
|
--title "[ M A I N - M E N U ]" \
|
|
|
|
--menu "Please Select An Option" 16 50 15 \
|
|
|
|
Accessories "General Programs" \
|
|
|
|
System "Main System Programs" \
|
|
|
|
Settings "Main System Settings" \
|
|
|
|
Multimedia "Audio & Video Programs" \
|
|
|
|
Graphics "Image Programs" \
|
|
|
|
Games "Gaming Programs" \
|
|
|
|
Office "Wordprocess & Documents Programs" \
|
|
|
|
Development "Programing Programs" \
|
|
|
|
Internet "Various Internet Related Programs" \
|
|
|
|
Wine "Windows Exe & Program Support" 2>"${INPUT}"
|
|
|
|
menuitem=$(<"${INPUT}")
|
|
|
|
case $menuitem in
|
2015-12-10 08:20:28 +00:00
|
|
|
Accessories) bash "${pth}"/Accessories.sh ;;
|
|
|
|
System) bash "${pth}"/System.sh ;;
|
|
|
|
Settings) bash "${pth}"/Settings.sh ;;
|
|
|
|
Multimedia) bash "${pth}"/Multimedia.sh ;;
|
|
|
|
Graphics) bash "${pth}"/Graphics.sh ;;
|
|
|
|
Games) bash "${pth}"/Game.sh ;;
|
|
|
|
Office) bash "${pth}"/Office.sh ;;
|
|
|
|
Development) bash "${pth}"/Development.sh ;;
|
|
|
|
Internet) bash "${pth}"/Internet.sh ;;
|
|
|
|
Wine) bash "${pth}"/Wine.sh ;;
|
2015-07-26 03:03:49 +00:00
|
|
|
Exit) echo "Bye!"; break ;;
|
|
|
|
esac
|
2015-04-09 21:30:24 +00:00
|
|
|
}
|
2015-07-26 02:55:27 +00:00
|
|
|
|
|
|
|
startScan()
|
|
|
|
{
|
|
|
|
clear
|
2015-12-10 08:20:28 +00:00
|
|
|
mkdir "${pth}"
|
|
|
|
touch "${pth}"/menu.list ;
|
|
|
|
sed -i "d" "${pth}"/menu.list ;
|
|
|
|
ls /usr/share/applications/ >> "${pth}"/menu.list ;
|
2015-07-26 03:03:49 +00:00
|
|
|
|
2015-12-10 08:20:28 +00:00
|
|
|
header='#!/bin/bash
|
2015-07-26 02:55:27 +00:00
|
|
|
INPUT=/tmp/menu.txt
|
2015-12-10 08:20:28 +00:00
|
|
|
dialog --clear --backtitle "Shellmen" \
|
|
|
|
--title "[ S U B - M E N U ]" \
|
|
|
|
--menu "Please Select An Option" 15 50 10 \
|
|
|
|
Main_Menu "Goes To Main Menu" \'
|
|
|
|
echo "$header" > "${pth}"/${accss}.sh
|
|
|
|
echo "$header" > "${pth}"/${dev}.sh
|
|
|
|
echo "$header" > "${pth}"/${gme}.sh
|
|
|
|
echo "$header" > "${pth}"/${int}.sh
|
|
|
|
echo "$header" > "${pth}"/${graph}.sh
|
|
|
|
echo "$header" > "${pth}"/${offce}.sh
|
|
|
|
echo "$header" > "${pth}"/${media}.sh
|
|
|
|
echo "$header" > "${pth}"/${sys}.sh
|
|
|
|
echo "$header" > "${pth}"/${settngs}.sh
|
|
|
|
echo "$header" > "${pth}"/${wine}.sh
|
2015-07-26 02:55:27 +00:00
|
|
|
menuHeaderInsert;
|
2015-04-09 21:30:24 +00:00
|
|
|
}
|
2015-07-26 02:55:27 +00:00
|
|
|
|
|
|
|
menuHeaderInsert()
|
|
|
|
{
|
2015-12-10 08:20:28 +00:00
|
|
|
x=$(cat "${pth}"/menu.list | wc -l) >> /dev/null ;
|
2015-04-09 21:30:24 +00:00
|
|
|
i="1"
|
2015-07-26 03:03:49 +00:00
|
|
|
|
|
|
|
while [ $i -le $x ]; do
|
2015-12-10 05:56:29 +00:00
|
|
|
# Reads the number of lines in list.txt then sets as a variable counting up to variable x
|
2015-12-10 08:20:28 +00:00
|
|
|
line1=$(sed -n "${i}p" "${pth}"/menu.list);
|
2015-07-26 03:03:49 +00:00
|
|
|
filename="${line1%.*}"
|
|
|
|
execMethod=$(grep -A 0 "Exec=" /usr/share/applications/"$line1")
|
|
|
|
catagory=$(grep -A 0 "Categories=" /usr/share/applications/"$line1")
|
|
|
|
preComment=$(grep -A 0 "Comment=" /usr/share/applications/"$line1")
|
|
|
|
comment=$(sed s/"Comment="//g <<< ${preComment})
|
2015-12-10 08:20:28 +00:00
|
|
|
inputer=$(echo ""\"$filename"\" "\"$comment"\" \\")
|
2015-07-26 03:03:49 +00:00
|
|
|
if [[ "$catagory" == *"$accss"* ]] || [[ "$catagory" == *"$util"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$inputer" >> "${pth}"/${accss}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$dev"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$inputer" >> "${pth}"/${dev}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$gme"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$inputer" >> "${pth}"/${gme}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$inputer" >> "${pth}"/${int}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$graph"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$inputer" >> "${pth}"/${graph}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$offce"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$inputer" >> "${pth}"/${offce}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$media*" ]] \
|
|
|
|
|| [[ "$catagory" == *"$vid"* ]] \
|
|
|
|
|| [[ "$catagory" == *"$audio"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$inputer" >> "${pth}"/${media}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$sys"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$inputer" >> "${pth}"/${sys}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$settngs"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$inputer" >> "${pth}"/${settngs}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$wine"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$inputer" >> "${pth}"/${wine}.sh
|
2015-07-26 03:03:49 +00:00
|
|
|
fi
|
2015-12-10 05:56:29 +00:00
|
|
|
i=$[$i++1];
|
2015-04-09 21:30:24 +00:00
|
|
|
done
|
2015-12-10 05:56:29 +00:00
|
|
|
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "2>"\"'${INPUT}'"\"" | tee -a "${pth}"/*.sh
|
|
|
|
echo 'menuitem=$(<"${INPUT}")' | tee -a "${pth}"/*.sh
|
|
|
|
echo "case \$menuitem in" | tee -a "${pth}"/*.sh
|
|
|
|
echo "Main_Menu) exec shellMen ;;" | tee -a "${pth}"/*.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
|
|
|
|
commandInsert;
|
2015-04-09 21:30:24 +00:00
|
|
|
}
|
2015-07-26 02:55:27 +00:00
|
|
|
|
|
|
|
commandInsert()
|
|
|
|
{
|
2015-12-10 08:20:28 +00:00
|
|
|
x=$(cat "${pth}"/menu.list | wc -l) >> /dev/null ;
|
2015-07-26 02:55:27 +00:00
|
|
|
i="1"
|
2015-07-26 03:03:49 +00:00
|
|
|
|
|
|
|
while [ $i -le $x ]; do
|
2015-12-10 08:20:28 +00:00
|
|
|
line1=$(sed -n "${i}p" "${pth}"/menu.list);
|
2015-07-26 03:03:49 +00:00
|
|
|
filename="${line1%.*}"
|
|
|
|
execMethod=$(grep -A 0 "Exec=" /usr/share/applications/"$line1")
|
|
|
|
catagory=$(grep -A 0 "Categories=" /usr/share/applications/"$line1")
|
|
|
|
preComment=$(grep -A 0 "Comment=" /usr/share/applications/"$line1")
|
2015-12-10 08:20:28 +00:00
|
|
|
execCMD=$(echo "${filename}) exec ${filename} ;;")
|
2015-07-26 03:03:49 +00:00
|
|
|
if [[ "$catagory" == *"$accss"* ]] || [[ "$catagory" == *"$util"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$execCMD" >> "${pth}"/${accss}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$dev"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$execCMD" >> "${pth}"/${dev}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$gme"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$execCMD" >> "${pth}"/${gme}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$execCMD" >> "${pth}"/${int}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$graph"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$execCMD" >> "${pth}"/${graph}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$offce"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$execCMD" >> "${pth}"/${offce}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$media*" ]] \
|
2015-12-10 08:20:28 +00:00
|
|
|
|| [[ "$catagory" == *"$vid"* ]] \
|
|
|
|
|| [[ "$catagory" == *"$audio"* ]]; then
|
|
|
|
echo "$execCMD" >> "${pth}"/${media}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$sys"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$execCMD" >> "${pth}"/${sys}.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
elif [[ "$catagory" == *"$settngs"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$execCMD" >> "${pth}"/${settngs}.sh
|
2015-07-26 03:03:49 +00:00
|
|
|
elif [[ "$catagory" == *"$wine"* ]]; then
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "$execCMD" >> "${pth}"/${wine}.sh
|
2015-07-26 03:03:49 +00:00
|
|
|
fi
|
2015-12-10 05:56:29 +00:00
|
|
|
i=$[$i++1];
|
|
|
|
done
|
2015-12-10 08:20:28 +00:00
|
|
|
echo "esac" | tee -a "${pth}"/*.sh
|
|
|
|
chmod +x "${pth}"/*.sh
|
2015-12-10 05:56:29 +00:00
|
|
|
mainMENU;
|
2015-04-09 21:30:24 +00:00
|
|
|
}
|
2015-04-16 04:39:00 +00:00
|
|
|
pre;
|