Here is a multi purpose script that I use to do some common things from a menu. It is easily expandable when I need to add more, here is current script:
#!/bin/bash
# Bash Menu Script Example
clear
PS3='
Please enter your choice: '
options=("G400s Setup" "Joystick config" "Joystick restore" "TeamViewer" "SSH Scaleway" "SSH OVH" "MIME rebuilt" "Quit")
select opt in "${options[@]}"
do
case $opt in
"G400s Setup")
clear
/home/omano/Scripts/G400sSetup.sh
break
;;
"Joystick config")
clear
echo "Do you want to configure and calibrate joystick?"
select yn in "Yes" "No"; do
case $yn in
Yes ) echo; echo "Close jstest-gtk to continue..."; jstest-gtk; echo "jstest-gtk closed..."; break;;
No ) echo; echo "Nothing recalibrated!"; break;;
esac
done
echo
echo "Which joystick would you like to store calibration for?"
select js in "JS0" "JS1" "ALL" "NONE"; do
case $js in
JS0 )
read -p "Are you sure? Y/N " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
sudo jscal-store /dev/input/js0; echo; echo "Saved JS0!";
fi
break;;
JS1 )
read -p "Are you sure? Y/N " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
sudo jscal-store /dev/input/js1; echo; echo "Saved JS1!";
fi
break;;
ALL )
read -p "Are you sure? Y/N " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
sudo jscal-store /dev/input/js0; sudo jscal-store /dev/input/js1; echo; echo "Saved all!";
fi
break;;
NONE) echo; echo "Nothing saved!"; break;;
esac
done
echo
break
;;
"Joystick restore")
clear
echo "Which joystick would you like to restore calibration?"
select js in "JS0" "JS1" "ALL" "NONE"; do
case $js in
JS0 ) sudo jscal-restore /dev/input/js0; echo; echo "Restored JS0"; break;;
JS1 ) sudo jscal-restore /dev/input/js1; echo; echo "Restored JS1"; break;;
ALL ) sudo jscal-restore /dev/input/js0; sudo jscal-restore /dev/input/js1; echo; echo "Restored ALL"; break;;
NONE) echo; echo "Nothing restored!"; break;;
esac
done
echo
read -p "Test joystick with jstest-gtk? Y/N " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
jstest-gtk
fi
break
;;
"TeamViewer")
clear
#teamviewer daemon start
sudo systemctl start teamviewerd.service
sleep 1
teamviewer
sleep 1
#teamviewer daemon stop
sudo systemctl stop teamviewerd.service
break
;;
"SSH Scaleway")
clear
ssh root@xxx.xxx.xxx.xxx
break
;;
"SSH OVH")
clear
ssh omano@xxx.xxx.xxx.xxx
break
;;
"MIME rebuilt")
clear
read -p "Clean WINE extensions and MIME? Y/N " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm -f ~/.local/share/applications/wine-extension*.desktop
rm -f ~/.local/share/icons/hicolor/*/*/application-x-wine-extension*
rm -f ~/.local/share/mime/packages/x-wine*
rm -f ~/.local/share/mime/application/x-wine-extension*
fi
rm -f ~/.local/share/applications/mimeinfo.cache
update-desktop-database ~/.local/share/applications
update-mime-database ~/.local/share/mime/
break
;;
"Quit")
clear
break
;;
*) echo "invalid option $REPLY";;
esac
done
Adding some of the sudo commands to the sudo with no passwords command makes life easier for having some of these commands or script on boot without issue or to not have to put paswords for these 'safe' commands (until I find a big security hole in doing so.. 'lol').
To do that simply executing sudo visudo and adding at the BOTTOM the following:
omano ALL= NOPASSWD: /usr/bin/evrouter -q,/usr/bin/rm -f /tmp/.evrouter*,/usr/bin/g400s_hack 3600 1,/usr/bin/evrouter --config=/home/omano/.evrouterrc /dev/input/event6