You could go about this another way. The coin is a button press or keystroke. A script can be written (likely) that will capture the key stroke regardless of the system running or just the front end and increase the count by 1. If 4 coins are inserted the count will be 4
Then each time you press start the button count would count down 4,3,2,1 etc.
Then the script could listen for running processes ex. Mame.exe or pifba.exe etc. this way if the process isn’t running and a user presses start it won’t decrease the counter.
In theory this would make emulated games like snes pay per play too as a user couldn’t send a start button unless coins were inserted.
I have wrote similar scripts in autohotkey for Windows and Mame but don’t have any real experience with Linux.
I’d like to see this happen, but people are very passionate about people charging for mame etc so your mileage may vary
Bh