Automatically run a command or program when I'm away from keyboard?
Is there any way to run a program when I am away from keyboard 开发者_JAVA百科after given timeout? For example, I want my torrent application to run automatically when I am away after 30 minutes. Was trying to find everywhere, but couldn't find any tool to do that.
On linux just use crontab. For Ubuntu it's explained here, but it will most likely apply to other linux distros too.
It's a bit more difficult under windows but this article describes it well.
What OS do you use? In Windows 7 or Vista you can create a scheduled task that will run a batch file or exe when the PC becomes idle. You can also define how long the PC has no input before it becomes idle.
In linux, you can use xautolock https://linux.die.net/man/1/xautolock
Despite its name, it can be used to run any command.
Xautolock monitors the user activity on an X Window display. If none is detected within mins minutes, a program is started as specified by the -locker option. Xautolock will typically be used to lock the screen (hence its primary name) but it really doesn't care what program you make it start. For this reason, xautolock does not interfere with the default X screen saver, unless the -resetsaver option is used. This implies that it is the job of the locker or the user to take the appropriate actions if the default screen saver is to be disabled. The only real assumption made by xautolock is that a new countdown starts as soon as the locker exits.
In windows, you can use the task scheduler.
https://learn.microsoft.com/en-us/windows/win32/taskschd/about-the-task-scheduler
Open the task scheduler. Create a new task. Create a new trigger. Use the "On idle" trigger. Create a new action to start the program. Modify the idle condition on the condition tab.
精彩评论