Shellmen/shellMen

185 lines
6.7 KiB
Plaintext
Raw Normal View History

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/>.
#---------------------------------------------------------------------------------------#
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
mainMENU;
else
startScan;
fi
}
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
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
menuHeaderInsert;
2015-04-09 21:30:24 +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
# 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
elif [[ "$catagory" == *"$dev"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$inputer" >> "${pth}"/${dev}.sh
elif [[ "$catagory" == *"$gme"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$inputer" >> "${pth}"/${gme}.sh
elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then
2015-12-10 08:20:28 +00:00
echo "$inputer" >> "${pth}"/${int}.sh
elif [[ "$catagory" == *"$graph"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$inputer" >> "${pth}"/${graph}.sh
elif [[ "$catagory" == *"$offce"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$inputer" >> "${pth}"/${offce}.sh
elif [[ "$catagory" == *"$media*" ]] \
|| [[ "$catagory" == *"$vid"* ]] \
|| [[ "$catagory" == *"$audio"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$inputer" >> "${pth}"/${media}.sh
elif [[ "$catagory" == *"$sys"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$inputer" >> "${pth}"/${sys}.sh
elif [[ "$catagory" == *"$settngs"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$inputer" >> "${pth}"/${settngs}.sh
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
i=$[$i++1];
2015-04-09 21:30:24 +00:00
done
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
commandInsert;
2015-04-09 21:30:24 +00:00
}
commandInsert()
{
2015-12-10 08:20:28 +00:00
x=$(cat "${pth}"/menu.list | wc -l) >> /dev/null ;
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%.*}"
2016-05-14 02:42:04 +00:00
execMethod=$(grep -A 0 -m2 "Exec=" /usr/share/applications/"$line1" | tail -n1)
2016-05-14 03:11:09 +00:00
execMethod=$(echo ${execMethod} | sed s/Exec=//g | sed s/%f//g | sed s/Try//g)
2015-07-26 03:03:49 +00:00
catagory=$(grep -A 0 "Categories=" /usr/share/applications/"$line1")
preComment=$(grep -A 0 "Comment=" /usr/share/applications/"$line1")
2016-05-14 02:42:04 +00:00
execCMD=$(echo "${filename}) ${execMethod} & shellMen ;;")
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
elif [[ "$catagory" == *"$dev"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$execCMD" >> "${pth}"/${dev}.sh
elif [[ "$catagory" == *"$gme"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$execCMD" >> "${pth}"/${gme}.sh
elif [[ "$catagory" == *"$int"* ]] || [[ "$catagory" == *"$net"* ]] ; then
2015-12-10 08:20:28 +00:00
echo "$execCMD" >> "${pth}"/${int}.sh
elif [[ "$catagory" == *"$graph"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$execCMD" >> "${pth}"/${graph}.sh
elif [[ "$catagory" == *"$offce"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$execCMD" >> "${pth}"/${offce}.sh
elif [[ "$catagory" == *"$media*" ]] \
2015-12-10 08:20:28 +00:00
|| [[ "$catagory" == *"$vid"* ]] \
|| [[ "$catagory" == *"$audio"* ]]; then
echo "$execCMD" >> "${pth}"/${media}.sh
elif [[ "$catagory" == *"$sys"* ]]; then
2015-12-10 08:20:28 +00:00
echo "$execCMD" >> "${pth}"/${sys}.sh
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
i=$[$i++1];
done
2015-12-10 08:20:28 +00:00
echo "esac" | tee -a "${pth}"/*.sh
chmod +x "${pth}"/*.sh
mainMENU;
2015-04-09 21:30:24 +00:00
}
mainMENU()
{
INPUT=/tmp/menu.txt
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
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 ;;
Exit) echo "Bye!"; break ;;
esac
}
pre;