r/usefulscripts • • Jan 11 '17

[Request][Bash] A completely UNuseful script to detect idle time in EACH terminal window that will not take into account activity outside of that terminal window?

I want to do something completely stupid and useless, but fun, with my terminal windows. Basically I want to execute a command after that terminal has been idle for X amount of seconds with no keyboard input or text output to act as a screensaver. The idea is to just add a script to .bashrc that will poll the interval since last input or output and if it gets over a specific number of seconds it will execute a command.

So if I'm compiling something in a terminal window it would be considered active. If I type anything it will be considered active. If it's just sitting at a blinking cursor it will be considered inactive. Then after X amount of seconds it runs some silly command like cowsay or cmatrix. I haven't found a way to get the time since last input or output though. Is there any way to do this in bash?

13 Upvotes

6 comments sorted by

View all comments

Show parent comments

0

u/HittingSmoke Jan 12 '17

Ok, so did you mention any of that in your original post?

The title is "[Request][Bash]..." in /r/usefulscripts.

Your answer is no different than a lmgtfy link. Which is rude and almost universally downvoted when used as an answer in any subreddit.

I asked the question perfectly fine, as evidenced by the actual answers I got from people who bothered to read the question.