how would I run a script or application when idle?

I would like to run various cryptocurrency generators, "miners" as they are known as, whenever my main pc is idle more then 30 minutes (no mouse or keyboard activity, etc.). How would I set this up?

edit: haven't picked what miners I'd use but I want to mine for bitcoin, litecoin, and namecoin right now.


Solution 1:

Two ideas:

nice

Run your program with a really low priority in the background. Use the nice command for that

nice -n 19 your_command &

19 is the lowest priority. You could create an autostart entry for that in ~/.config/autostart/ This works best for CPU intensive tasks, not IO intensive ones.

A disadvantage is that it's always running.

dbus hook

Gnome screensaver fires a dbus event; when this event is fired, you could invoke a script.

See How do you get Ubuntu to automatically run a program every time the screen is unlocked? on superuser.com.

I have not tried this though.