I have a device that connects via USB when a button is pressed. It immediately ceases the connection, when the button is released. I want to start a graphical application when I press this button.
I could successfully access the button and start the application. The problem is that when I press the button multiple times, the application restarts again and again after being closed, because udev apparently queues the events or holds them until they can be processed.
So I wrote a bash script that checks whether the application is running. When it is not running it starts the application. When it is running it maximizes the application. Here the same problem occurred, so I tried to start the application in the background with
&, but then it is killed when the udev rule has finished. Same with
Maybe a bash script is not the best way here. I need a script that can start a long-term application in a separate process, so the script can finish and be run again. It should, if possible, also be a Linux native method, so I don't have to install more dependencies.
I found this thread How to run long time process on Udev event? that deals with the same problem. He appearently solved it with using
cmd | at now, but this commands seems to be deprecated, since cronie doesn't have this command like cron did.
I just found out that at is a package you need to install, but then the application also starts multiple times and the script doesn't finish.
I am running Manjaro, so basically Arch.