I was looking for a solution where I could have various shutdown options when exiting AM, like you get with Retropie / Emulation Station, where you can choose to shutdown, restart, exit do desktop, etc.
After a lot of searching, I didn't really find a suitable solution other than adding something to the Exit Command in AM.
I came up with the idea of running a shell script with a basic menu in it and putting it in the Exit command, but it didn't work. AM just locked up on exit and I would have to kill the AM process.
I then tried adding attract to the begining of the script to launch AM then when it exits then run the menu and running that when the OS started.
This worked when run from a terminal window, but when I launched it at startup, when AM exited, it didn't run the menu.
I have now found a solution that works, so thought i would share it in case anyone else wants to do a similar thing.
I'm running Ubuntu, so if you are using a different version of Linux, you may have to modify things slightly to get it to work.
So first of all I made the script, which has 3 options - Exit to desktop, reboot & shutdown. But you can obviously add more.
I called it Attract.sh and put it in the root of my home directory (in my case /home/sf)
The script uses dialog to make the menu, so if you don't have it, you will need to install it - sudo apt install dialog
to make the script
cd
sudo nano Attract.sh
copy this into it
#!/bin/bash
attract
HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=4
BACKTITLE="EXIT ATTRACT MODE"
TITLE="EXIT OPTIONS"
MENU="Choose one of the following options:"
OPTIONS=(1 "EXIT TO DESKTOP"
2 "SHUT DOWN MACHINE"
3 "RESTART MACHINE")
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
1)
echo ""
;;
2)
sudo shutdown now
;;
3)
sudo reboot
;;
esac
Now in the ubuntu desktop, go to your applications and select 'startup applications'
If you already have attract mode in there, you will need to remove it or untick it.
Click the Add button and give it a name. Then in the command option type
gnome-terminal --full-screen --hide-menubar --command /home/sf/Attract.sh
** replace sf with your user directory name **
Then click save
What this does on startup is, open a terminal window and run the script which launches AM then runs the menu when AM exits.
The terminal is run full screen and has the menu bar disabled.
inadvertently, this has also solved another issue I had where, during startup and when launching a game, the Ubuntu desktop would show for a brief second. Now it just shows the terminal screen.
Hope this is of some use to some people.